What are the syntax errors in the SQL query provided in the code snippet?
The syntax errors in the SQL query are: 1. Missing quotes around the table name "users". 2. Missing comma after the "name" column in the SELECT statement. 3. Incorrect table alias "u" used in the WHERE clause. To fix these issues, add quotes around the table name "users", add a comma after the "name" column, and use the correct table alias "users" in the WHERE clause.
// Corrected SQL query
$sql = "SELECT id, name, email FROM `users` WHERE users.name = 'John'";
// Execute the query
$result = mysqli_query($conn, $sql);
// Check if the query was successful
if ($result) {
// Process the results
while ($row = mysqli_fetch_assoc($result)) {
echo "ID: " . $row['id'] . ", Name: " . $row['name'] . ", Email: " . $row['email'] . "<br>";
}
} else {
echo "Error: " . mysqli_error($conn);
}