The answer you entered to the math problem is incorrect.

MySQL Query keeps failing (no replies)

I have this script I made but I keep getting this error when i load the page:

Query failed: 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 'AND `new_topic` = 1 ORDER BY `post_date`' at line 1

My code for that part:

mysql_connect ($databaseip, $username, $password)

or die ("Couldn't connect to server");

mysql_select_db ($databasename)

or die ("Couldn't Select DB");

$topicq = mysql_query ("SELECT * FROM `ibf_topics` WHERE `forum_id` = ".$forumid." ORDER BY `start_date` DESC")

or die("Query failed: " . mysql_error());

for ($i=0; $i <$topicrows; $i++)

{

$topicrow = mysql_fetch_array($topicq);

$titleid = $topicrow["tid"];

$topictitle = ($topicrow["title"]);

$postq = mysql_query ("SELECT * FROM `ibf_posts` WHERE `topic_id` = ".$titleid." AND `new_topic` = 1 ORDER BY `post_date`")

or die("Query failed: " . mysql_error());

$postfetch = mysql_fetch_array($postq);

$postrow = $postfetch["post"];

$unixdate = $topicrow["start_date"];

$date = date("F jS, Y",$unixdate);

$writter = $topicrow["starter_name"];

$postrow = str_replace('<#EMO_DIR#>', $emoticons, $postrow);

$postrow = str_replace('<#IMG_DIR#>', $img_dir, $postrow);

Can you tell me what is wrong with it?

Thanks!

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.