I need help with this query. If I use this query in MySQL that works fine but is not being executed when used in PHP.
$sql = "INSERT INTO dtable (name, mobile, email) VALUES (‘".$MP_Name."’, ‘".$MP_Mobil."’,’".$MP_Email."’);";
$conn->query($sql);
I need help with this query. If I use this query in MySQL that works fine but is not being executed when used in PHP.
$sql = "INSERT INTO dtable (name, mobile, email) VALUES (‘".$MP_Name."’, ‘".$MP_Mobil."’,’".$MP_Email."’);";
$conn->query($sql);
3
Answers
With more study, I came to know that I was actually getting an error; commands out of sync; you can't run this command now.
I added $conn->next_result() before running the query which solved the issue.
Use prepared statements to avoid sql injection.
Try to echo the query string before executing it and copy/paste that echoed query in phpmyadmin and check for errors in the query