eRott Posted December 4, 2009 Share Posted December 4, 2009 Hey guys, I keep getting this 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 'WHERE subject='Application: Jaxxit'' at line 1 Its from this query: mysql_query("INSERT INTO mybb_threads (appid) VALUES ('$appid') WHERE subject='Application: $char_name'") or die(mysql_error()); Does anyone know what is wrong with it? Thanks. Link to comment https://forums.phpfreaks.com/topic/183933-syntax-error/ Share on other sites More sharing options...
corbin Posted December 4, 2009 Share Posted December 4, 2009 Errr..... What are you trying to do? A WHERE clause in an INSERT statement makes no sense. Link to comment https://forums.phpfreaks.com/topic/183933-syntax-error/#findComment-970986 Share on other sites More sharing options...
eRott Posted December 4, 2009 Author Share Posted December 4, 2009 I need to insert a value into a pre-existing row in a table. Here's the basic break-down: 1) User fills out a form. 2) A thread is created in [table A] (MyBB) with data gathered from the form 3) Insert portions of the data gathered from the form into [table B] as well I need a means of linking both the item in [table A] and the item in [table B] together for future queries. I opted for creating a new field in [table A] and inserting the ID number of the item inserted into [table B]. The problem is, I need to insert the ID number from the item in [table B] into the correct item in [table A]. It is proving to be difficult since there really isn't any pre-existing unique value which I could use to link the item in [table A] to the one in [table B]. I think I may just end up generating a random salt, throwing it in each upon creation and linking them that way. Unless of course you see a solution to the problem I mentioned earlier. Oh my... its 12:00. I have to get up in 5 hours for work. I'll check back here tomorrow. Link to comment https://forums.phpfreaks.com/topic/183933-syntax-error/#findComment-970998 Share on other sites More sharing options...
fenway Posted December 4, 2009 Share Posted December 4, 2009 That's called an UPDATE. Link to comment https://forums.phpfreaks.com/topic/183933-syntax-error/#findComment-971249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.