For testing inserts, I always use the name of Béänny'O so I can make sure my code can handle the various accent characters in different names. Today, however, I'm missing something because the database is returning an error when I try to insert. Here is part of the error, which proves it doesn't like the apostrophe after the y in the name.
Error: mysql_errno() You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'O'
The weird thing is my insert PHP code is the same as all my other inserts:
$emailBody = "User is Béänny'O Smith";
$addNotification = "INSERT INTO notifications (messageHTML, address) VALUES ('".mysql_real_escape_string($emailBody)."', '$senderEmail')";
mysql_query($addNotification) OR die("<p>Please email us the following information:</p> <p>Query: $addNotification </p> <p>Error: mysql_errno() " . mysql_error() );
Any thoughts on this?
Put the closing ") at the end of the SQL statement. The entire OR DIE part isn't SQL, it's PHP.
This topic is now closed. New replies are no longer allowed.