Forum Moderators: coopster

Message Too Old, No Replies

mysql update query help

         

bleak26

9:33 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



I have been trying to use the query at the bottom to update fields in my shirts table but i keep getting this error. can you tell me what is happening.

: 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 's' , tshirts.saleslink = 'smoo', tshirts.imagelink = 'smoo' ,

sql_query = " UPDATE tshirts SET catagory = '$catagory',
shirtname = '$shirtname',
tshirts.sex = '$sex',
tshirts.size = '$size',
tshirts.colour = '$colour',
tshirts.price = '$price' ,
tshirts.material = '$material',
tshirts.salestext '$salestext',
tshirts.shortsalestext = '$shortsalestext' ,
tshirts.saleslink = '$saleslink',
tshirts.imagelink = '$imagelink',
tshirts.lastentered = '$lastentered'
WHERE tshirts.tshirtid = '$tshirtid' ";

Birdman

10:11 pm on Sep 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The best way to troubleshoot SQL(with variables) is to print the actual query to the page. Right after you set up your query, add this line:

print $sql_query;

I imagine you have an unescaped single quote in one of the entries. If so, do addslashes() to any field that 'could' have a single quote in it.

Regards,
Birdman

Refs:
[us4.php.net...]
[us4.php.net...]

Netizen

11:57 am on Sep 24, 2004 (gmt 0)

10+ Year Member



Or if that is the exact query then

sql_query = " UPDATE tshirts SET catagory = '$catagory',
shirtname = '$shirtname',
tshirts.sex = '$sex',
tshirts.size = '$size',
tshirts.colour = '$colour',
tshirts.price = '$price' ,
tshirts.material = '$material',
tshirts.salestext '$salestext',
tshirts.shortsalestext = '$shortsalestext' ,
tshirts.saleslink = '$saleslink',
tshirts.imagelink = '$imagelink',
tshirts.lastentered = '$lastentered'
WHERE tshirts.tshirtid = '$tshirtid' ";

the bold line is missing a "=".