php 4.3.0-dev and MySQL 4.0.4-beta (problems with insert)
| From: | Tyler Longren | Date: | Wed, 23 Oct 2002 17:09:36 +0000 |
| Subject: | php 4.3.0-dev and MySQL 4.0.4-beta (problems with insert) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-121134@lists.php.net to get a copy of this message | ||
Hello,
I just upgraded from MySQL 3 to MySQL 4. I also upgraded from the
latest php 4.2 to php 4.3.0-dev.
When I try to insert something into a database that contains a ', I get
errors:
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
't','10-23-2002 12:11:23','20021023121123')' at line 1
Here's the code that worked with MySQL 3:
$sql = mysql_query("INSERT INTO news (title,content,date,timestamp)
VALUES('$_POST[title]','$_POST[content]','$date','$ts')");
I've tried addslashes(), but it doesn't help any.
The text I entered in "title" was "don't". I realize this is a problem
with MySQL, but I thought I'd ask here first, this list isn't as mean as
the mysql list. I know it's a problem with mysql because the same thing
happens when I downgrade my versions of PHP (back to php 4.2).
Anyone have any ideas?
Thanks,
Tyler