YourNameHere Posted November 4, 2009 Share Posted November 4, 2009 This is a stupid easy one but cant for the life of me find the solution. I have a table that holds an ID and 6 empty columns for later use. when I try and select the right id and then populate 1 or more of the empty columns I get a syntax 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 chatId = 'Chat_1257295904'' at line 1 here is the statement: INSERT into invites (player1) values ('Cody') WHERE chatId = 'Chat_1257295904' this is how the table is set up: columns; chatId, player1 - player6 Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/ Share on other sites More sharing options...
smerny Posted November 4, 2009 Share Posted November 4, 2009 what type is chatId? Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/#findComment-950674 Share on other sites More sharing options...
xtopolis Posted November 4, 2009 Share Posted November 4, 2009 In the way you describe your setup, shouldn't you be using an update instead? UPDATE invites SET player1 = 'Cody' WHERE chatId = 'Chat_1257295904''; It doesn't seem like the string "Cody" is stored in another table by the way you described it. Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/#findComment-950724 Share on other sites More sharing options...
YourNameHere Posted November 4, 2009 Author Share Posted November 4, 2009 You're probubly right about an update being correct. and Cody is stored elsewhere in another table, it's a username. chatId is varchar(40) it stores "chat_16516579" where the numbers are the timestamp when the chat was created. Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/#findComment-950746 Share on other sites More sharing options...
smerny Posted November 4, 2009 Share Posted November 4, 2009 if i were you i'd use an auto increment primary id for the chatId.... and if you wanna store a time, use another column anyway, did you switch to update? if so show the surrounding code so we can see the quotes used and such Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/#findComment-950749 Share on other sites More sharing options...
YourNameHere Posted November 4, 2009 Author Share Posted November 4, 2009 Yes I switched to update and it worked. thanks. The time is just there to make it unique. Quote Link to comment https://forums.phpfreaks.com/topic/180215-solved-insert-into-where/#findComment-950850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.