Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Query failed

  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Query failed

    i got this error when am doing this
    and cantfind the problem
    PHP Code:
    <?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);
                }

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    What's the error?

  • Users who have thanked Mwnciau for this post:

    ausgezeichnete (11-04-2007)

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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..

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    order by field_name DESC limit ....
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    ausgezeichnete (11-04-2007)

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    $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

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    .... desc limit " ...

    limit 0 12
    (note the space b/w them)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thnxxxxxx it workeddd noww


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •