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

    Thumbs down mysqli_num_rows expects???

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\wamp\www\Forum\forumregister.php on line 32
    and this my code:
    PHP Code:
    $conn=mysqli_connect("localhost","root","","cars");
    $query=mysqli_query($conn,"select * from users where name='".$username."' ");
    //////if the name doesnt exists //////////
        
    [B]if(mysqli_num_rows($query)==0){[/B]
            
    /////insert the data if not existed/////
            
    $query=mysqli_query($conn,"insert into users (name,password,email,showemail)
            values('"
    .$username."',password('".$password."'),'".$email."','".$showemail."' )" );
                if(
    $query){
                    
    $logged_in_user=$username;
                    
    session_register("logged_in_user");
            
    $query=musqli_query("select userID from users where name='".$username."'");
                    if(!
    $query)fail("database query faild",true);
                    
    $record=mysqli_fetch_assoc($query);
                    
    $logged_userID=$record["userID"];
                    
    session_register("logged_userID"); 
    why????

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Your query is failing, try echoing mysqli_error()

  • Users who have thanked Mwnciau for this post:

    ausgezeichnete (11-03-2007)

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Try getting right angle quotes around your query, they would go around any table identifier (database, table, cell...). If found that to throw my queries off.

    Code:
    $query=mysqli_query($conn,"SELECT * FROM `users` WHERE `name`='".$username."' ");
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • Users who have thanked gnomeontherun for this post:

    ausgezeichnete (11-03-2007)

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    i tried echo mysqli_error($query);
    and gave me:

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\wamp\www\Forum\forumregister.php on line 33
    technical error considering adding your details
    Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in D:\wamp\www\Forum\forumregister.php on line 55

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    well it worked now
    but i got another error now
    in the logic i guess

  • #6
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts
    my problem was usig WRONG database


  •  

    Posting Permissions

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