What are some potential performance issues with using MySQL queries in PHP scripts?

One potential performance issue with using MySQL queries in PHP scripts is not properly indexing the database tables. This can lead to slow query execution times, especially when dealing with large datasets. To solve this issue, make sure to add indexes to columns that are frequently used in WHERE clauses or JOIN conditions.

// Example of adding an index to a column in MySQL table
$sql = "ALTER TABLE users ADD INDEX idx_username (username)";
$result = mysqli_query($conn, $sql);
if ($result) {
    echo "Index added successfully";
} else {
    echo "Error adding index: " . mysqli_error($conn);
}