Results 1 to 2 of 2
Oct 25, 2013, 20:36 #1
- Join Date
- Sep 2004
- Provo, UT
- 1 Post(s)
- 0 Thread(s)
Getting an error trying to do an insert
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?
Thanks!Convert your dollars into silver coins. www.convert2silver.com
Oct 26, 2013, 01:20 #2
Put the closing ") at the end of the SQL statement. The entire OR DIE part isn't SQL, it's PHP.Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget