...

View Full Version : mysql_num_rows problem



zodehala
01-10-2012, 02:34 PM
$link = mysql_connect("localhost", "root", "123");
mysql_select_db("db", $link);

$result = mysql_query("SELECT * FROM kul WHERE kuladi = root");
if(mysql_num_rows($result)!=1){
echo "no user";

}


gives following error. why?


Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\tekoser\x.php on line 6

BluePanther
01-10-2012, 02:40 PM
It's because your query is throwing an error and you're not catching it. wrap root in ' to define it as a string.

Use or die() statements or something else to catch mysql errors.

Also, you've just told the world your database root password. Remember to censor sensitive information when posting here.

zodehala
01-10-2012, 03:02 PM
db user root and pass123

user ind db is root and his pass is 123

BluePanther
01-10-2012, 03:05 PM
db user root and pass123

user ind db is root and his pass is 123

What? That's completely unrelated to my answer.

BluePanther
01-10-2012, 03:08 PM
You edited your post as I replied. The user for the database is (and definitely should be) different from users stored in the database.

You're telling us your database user and pass! These forums are open to the public!

Your problem is in your sql query - a syntax error like I said.

tangoforce
01-10-2012, 10:10 PM
You edited your post as I replied.

I'm not seeing the traditional "Last edited.." line anywhere :confused:

BluePanther
01-10-2012, 10:14 PM
I'm not seeing the traditional "Last edited.." line anywhere :confused:

It doesn't appear if you edit within a certain time frame :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum