Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,940
38
Australia
So, when I run this code:
PHP:
$sql = "INSERT INTO table1 (".$insertInto.") VALUES ('".$nm."') WHERE id = ".$id;
if (!mysql_query($sql, $con)) {
	die("xgkzr ".mysql_error());
}
I get this error:
Code:
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 'WHERE id = '2'' at line 1
Any idea's what's wrong with that code?

I want it to find id 2 in table1 and insert into the row "comp1" the value "test1".

EDIT: Solution: using Update not INSERT INTO... IE, INSERT INTO table1 SET table1='value' WHERE id = 0.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.