tfe Posted July 6, 2011 Share Posted July 6, 2011 Hello, What's wrong in this query? It returns syntax error. $result = mysql_query("INSERT INTO messages_folders(id,recipient,sender,number,updated,title) VALUES ('" . implode(',',$folders) . "') ON duplicate KEY UPDATE number=number+1") or die(mysql_error()); Thanks. Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/ Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 MySQL error or PHP error? Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239018 Share on other sites More sharing options...
tfe Posted July 6, 2011 Author Share Posted July 6, 2011 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 '10618','60', '1', '1309958664', 'test')') ON duplicate KEY UPDATE number=num' at line 1 Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239025 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 You should start by echoing your query. Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239028 Share on other sites More sharing options...
tfe Posted July 6, 2011 Author Share Posted July 6, 2011 Changed query to: $result = mysql_query("INSERT INTO messages_folders(id,recipient,sender,number,updated,title) VALUES (".implode(",", $folders).") ON duplicate KEY UPDATE number=number+1") or die(mysql_error()); Now I am getting another error: Column count doesn't match value count at row 1 Don't know how is it possible if $folder value count is the same: array_push($folders, "(NULL,'$tid','$id','1','$timestamp','$name')"); Maybe I need to open another thread. Actually I am looking for solution how to send/delete multiple mssages at the same time (with implode) and then to update number of messages for each folder. Updating doesn't work correctly if I use "implode". Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239040 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 You want to echo out the query. You'll see what's going wrong. Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239044 Share on other sites More sharing options...
tfe Posted July 6, 2011 Author Share Posted July 6, 2011 Here is the echo result: INSERT INTO messages_folders(id,recipient,sender,number,updated,title) VALUES ((NULL,'10618','60','1','1309962951','test')) ON duplicate KEY UPDATE number=number+1 I don't see any problem but this query still returns error: "Column count doesn't match value count at row 1" Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239056 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 Double parenthesis. It's treating your second set of brackets as a single column, I think Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239064 Share on other sites More sharing options...
tfe Posted July 6, 2011 Author Share Posted July 6, 2011 Ohh, thank you very much. It's OK now. Link to comment https://forums.phpfreaks.com/topic/241212-mysql-query-syntax-error-problem/#findComment-1239070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.