...

View Full Version : mysqli_num_rows expects???



ausgezeichnete
11-03-2007, 05:42 PM
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:


$conn=mysqli_connect("localhost","root","","cars");
$query=mysqli_query($conn,"select * from users where name='".$username."' ");
//////if the name doesnt exists //////////
if(mysqli_num_rows($query)==0){
/////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????

Mwnciau
11-03-2007, 06:12 PM
Your query is failing, try echoing mysqli_error()

gnomeontherun
11-03-2007, 06:24 PM
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.


$query=mysqli_query($conn,"SELECT * FROM `users` WHERE `name`='".$username."' ");

ausgezeichnete
11-03-2007, 06:31 PM
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
11-03-2007, 08:13 PM
well it worked now
but i got another error now
in the logic i guess

ausgezeichnete
11-03-2007, 08:14 PM
my problem was usig WRONG database



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum