mysql_query() ERROR
| From: | Fifield, Mike | Date: | Wed, 21 Aug 2002 13:36:44 +0000 |
| Subject: | mysql_query() ERROR | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-113458@lists.php.net to get a copy of this message | ||
This is a query that I am sending to mysql. The problem is that sometimes in
the variable "$message" characters like ")" will get posted and when they do
it makes mysql die. I can only assume that mysql thinks that the ")" in the
$message variable is meant to close the sql query, but I am having trouble
figuring out how to avoid this. I suppose I could use a regex to replace all
special characters with something more sql friendly but I am hoping there is
a better way to do this. Thanks for any help.
mysql_query("insert into guestbook
(gb_entry_id,date,name,email,website_name,website_url,message) values
('',CURDATE(),'$name','$email','$website_name','$website_url','$message')")
or die (mysql_error());