$editquery = "UPDATE ads SET 468='$a468', 720='$a720', 300='$a300', 120='$a120', 160='$a160' where user='$user'"; mysql_query( $editquery ) or die ( "Update error: ".mysql_error() ); Code (markup): This produces the error: Update error: 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 '468='grrewhba', 720='reaghhrgreagg', 300='rgaerg', 120='eargeearg', 160='rgagra'' at line 1 But I can't see anything wrong with it? Cheers, Nick
Here my universal solution for all kind of mysql problems Echo "query" statement, copy it and paste it into phpmyadmin and try to see what errors are. Then generate with phpmyadmin a valid query statement using same fields/criteria and compare the two statements to see what's different and how should you modify the original query to make them look and behave the same. Try it
Thanks, but hasnt really helped, the result was full of a ridiculous amount concatenation etc, which isn't necessary....
It's not that I don't appreciate the advice, I do, I've used that method before, but it doesn't work very well in this situation: $sql = 'UPDATE `ads` SET `468` = \'blah' . ' trhrths\', `720` = \'blah' . ' rhesrjh\', `300` = \'blah' . ' esrhes\' WHERE `ads`.`id` = 0 LIMIT 1;'; When $editquery = "UPDATE ads SET 468='$a468', 720='$a720', 300='$a300', 120='$a120', 160='$a160' where user='$user'"; mysql_query( $editquery ) or die ( "Update error: ".mysql_error() ); Should work fine?
Ahh if I wrap the column id's with ` ` it works fine, never had to do that before, seems sql statements dont like plain old numbers as the col id's without the ` round them.
Yeah, just wanted to say that you at least should use backticks for column names, because i never saw anyone using numbers as col.names.