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 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    5
    Thanked 0 Times in 0 Posts

    query doesn't run?

    I am very new to mysql, i have created the following code to run a query and obtain the results but keep getting this message
    "mysqli_fetch_object() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\create_auction.inc.php on line 26"
    i don't understand why??

    PHP Code:
    <?php
    include('header.html');
    $user $_SESSION['username'];
    $userid $_SESSION['userid'];

    if(!
    session_is_registered('username')) {
        echo 
    "you must be logged in";

    }else{
        
        include(
    'connect.php');
        
        
    $track $_POST['track'];
        
    $month $_POST['months'];
        
    $week $_POST['weeks'];
        
    $rprice $_POST['rprice'];
        
    $q "SELECT track_id FROM tracks WHERE username='$user' AND title = '$track'";
    //$r = @mysqli_query ($dbc, $q);

    $result = @mysqli_query($dbc$q);
    $row=mysqli_fetch_object($result);


    }
    Last edited by oracleguy; 02-26-2009 at 04:48 PM.

  • #2
    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
    Try
    PHP Code:
    $result mysqli_query($dbc$q) or die(mysql_error()); 
    instead of
    Code:
    $result = @mysqli_query($dbc, $q);
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Please wrap your code using the code tags in the future. (Or the php tag if the code is php) I fixed up your post for you.
    OracleGuy

  • #4
    New Coder
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    5
    Thanked 0 Times in 0 Posts
    i added the following, it stops giving an error but does not echo?



    PHP Code:
    $row mysqli_fetch_object($result);
    $trackid $row->track_id;
    echo 
    "$trackid"

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Do you know if you even fetched a row? Use mysqli_num_rows() to find out if you did.

    http://us2.php.net/manual/en/mysqli-result.num-rows.php


  •  

    Posting Permissions

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