SyncViews Posted April 19, 2008 Share Posted April 19, 2008 74: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 ')' at line 6 <?php ... //update forums $parents_str = ''; foreach($parents as $i=>$parent) { if($i==0)$parents_str . $parent["id"]; else $parents_str . ", $parent[id]"; } $sql->query(" UPDATE forums SET topics=topics+1, posts=posts+1, last_topic_name='$subject', last_topic_id=$topic_id, last_post_id=$post_id, last_post_time=$time, last_user_id=$user_id, last_user_name='$user_name' WHERE forum_id IN ($parents_str) ") or exit(__LINE__.':'.$sql->error); ... Link to comment https://forums.phpfreaks.com/topic/101795-sql-error/ Share on other sites More sharing options...
hitman6003 Posted April 19, 2008 Share Posted April 19, 2008 $parents_str is probably empty, which means your query has "WHERE forum_id IN ()", which will generate an SQL error. Echo out the query to check. Link to comment https://forums.phpfreaks.com/topic/101795-sql-error/#findComment-520859 Share on other sites More sharing options...
haku Posted April 19, 2008 Share Posted April 19, 2008 $parents_str is probably empty Not just probably - it IS empty! (he defines it as empty at the start of his script). Link to comment https://forums.phpfreaks.com/topic/101795-sql-error/#findComment-520997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.