Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-03-2007, 05:42 PM   PM User | #1
ausgezeichnete
New Coder

 
Join Date: Oct 2007
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
ausgezeichnete is an unknown quantity at this point
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????
ausgezeichnete is offline   Reply With Quote
Old 11-03-2007, 06:12 PM   PM User | #2
Mwnciau
Regular Coder

 
Join Date: May 2006
Location: Wales
Posts: 820
Thanks: 1
Thanked 82 Times in 79 Posts
Mwnciau is on a distinguished road
Your query is failing, try echoing mysqli_error()
Mwnciau is offline   Reply With Quote
Users who have thanked Mwnciau for this post:
ausgezeichnete (11-03-2007)
Old 11-03-2007, 06:24 PM   PM User | #3
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Users who have thanked gnomeontherun for this post:
ausgezeichnete (11-03-2007)
Old 11-03-2007, 06:31 PM   PM User | #4
ausgezeichnete
New Coder

 
Join Date: Oct 2007
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
ausgezeichnete is an unknown quantity at this point
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
ausgezeichnete is offline   Reply With Quote
Old 11-03-2007, 08:13 PM   PM User | #5
ausgezeichnete
New Coder

 
Join Date: Oct 2007
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
ausgezeichnete is an unknown quantity at this point
well it worked now
but i got another error now
in the logic i guess
ausgezeichnete is offline   Reply With Quote
Old 11-03-2007, 08:14 PM   PM User | #6
ausgezeichnete
New Coder

 
Join Date: Oct 2007
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
ausgezeichnete is an unknown quantity at this point
my problem was usig WRONG database
ausgezeichnete is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:01 AM.


Advertisement
Log in to turn off these ads.