...

View Full Version : Query failed



ausgezeichnete
11-04-2007, 03:03 PM
i got this error when am doing this
and cantfind the problem


<?php session_start();
require "forum.inc.php";
if(!$logged_userID){
fail("not logged","true");
}
setup_page("Great Debate","Topic for debate");
$thread_per_page=12;
if(!$thread_list_offset){$thread_list_offset=1;}
$thread_list_offset +=$increment * $thread_per_page;
session_register("thread_list_offset");
$conn=mysqli_connect("localhost","root","","forum");
$query=mysqli_query($conn,
"select thread.title,thread.threadID ,MAX(posts.dateposted) as latest
from thread ,posts where thread.threadID =posts.threadID
group by thread.threadID order by desc
limit" .($thread_list_offset-1).",".$thread_per_page );
if(!$query){
fail("Query failed","true");
echo mysqli_error($conn);
}

Mwnciau
11-04-2007, 03:25 PM
What's the error?

ausgezeichnete
11-04-2007, 03:36 PM
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 'desc limit 0,12' at line 3
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\wamp\www\Forum\forummain.php on line 22

usermahaLogout

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in D:\wamp\www\Forum\forummain.php on line 28
Thread title Last Post on..

abduraooft
11-04-2007, 03:47 PM
order by field_name DESC limit ....

ausgezeichnete
11-04-2007, 04:07 PM
$query=mysqli_query($conn,
"select thread.title,thread.threadID ,MAX(posts.dateposted) as latest
from thread ,posts where thread.threadID =posts.threadID
group by thread.threadID order by latest desc limit"
.($thread_list_offset-1).",".$thread_per_page );
and i got that:
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 'limit0,12' at line 3

abduraooft
11-04-2007, 04:10 PM
.... desc limit " ...

limit 0 12
(note the space b/w them)

ausgezeichnete
11-04-2007, 04:19 PM
thnxxxxxx it workeddd noww



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum