PDA

View Full Version : update


IKinsler
07-30-2002, 05:31 PM
update $category set name=$name , image=$image , price=$price , stock=$stock , description=$description where name = '$name'

Obviously there is something wrong with that query, can anybody spot it?

Thanks!
Jared

Jeewhizz
07-30-2002, 10:47 PM
update '$category' set name='$name' , image='$image' , price='$price' , stock='$stock' , description='$description' where name = '$name'

Hope this helps mate

Jee

IKinsler
07-31-2002, 05:24 AM
Thanks for helping, but it still doesn't seem to work.

Spookster
07-31-2002, 05:49 AM
You will need to be more descriptive of what's not working. Is is generating an error? Is the query running and the fields not being updated?

IKinsler
07-31-2002, 06:57 AM
if (mysql_query("my query is here")) {
echo "yes";
} else {
echo "no";
}

It returns no.

Jeewhizz
07-31-2002, 06:26 PM
Try this and paste the results

if (mysql_query("my query is here")) {
echo "yes";
} else {
echo "no<br />".mysql_error();
}

Jee

IKinsler
07-31-2002, 06:30 PM
You have an error in your SQL syntax near ''' set name='Matrix' , image='' , price='2.00' , stock='No' , description='The p' at line 1

Could it be that I want the image to be blank?

mordred
08-02-2002, 12:15 AM
No, that shouldn't bother MySQL. Far more interesting is what is contained in $category at the time you send your query. Put your query string in a variable like $sql and echo it so you can see for yourself if the value is valid.

I don't know exactly if that's important, but I don't use single quotes (') around my table name... though I don't know if they're allowed or not, but the documentation doesn't use them either.