Log in

View Full Version : Problems with quotes after moving database



Mikee
08-13-2009, 10:03 AM
Hi to all,

I moved a db from a website to another but i have big trouble with single/double quotes. I've recreated the site and built a new database with the same name as the original database. When I try to update an old article on the website I get the following error..


I'm givin' her all she's got, Captain, but we need more power!
This error said :
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 've seen and manage your video collection.', `DESCRIPTION` = 'Coollector is a gre' at line 1

And this because the description of the article contains a single quote:


Coollector Movie Database: track the movies you've seen and manage your video collection.

The old website MySQL version: 5.0.81
The new website MySQL version: 5.1.30

Pls. help me with a simple soution, it's been two days since i try and i try and I'm going crazy.

Thank you in advance.

forum_amnesiac
08-14-2009, 11:49 AM
Without seeing your PHP code this is caused by the ' in the string.

This would cause your problem.


$string="I'm givin' her all she's got, Captain, but we need more power!";

$result = mysql_query ("INSERT INTO table (field) VALUES ('$string')");

There are 2 many single quotes in the field insert value.

If you do this, using the "american" quotes, it should work


$string="I'm givin' her all she's got, Captain, but we need more power!";

$result = mysql_query ("INSERT INTO table (field) VALUES (`$string`)");

Schmoopy
08-14-2009, 12:03 PM
Following on from what amnesiac has said, you could keep the string in single quotes, but just escape them:



$string='I\'m givin\' her all she\'s got, Captain, but we need more power!';