Click to See Complete Forum and Search --> : what's wrong in mysql_num_rows() function?? Help


snoopy0877
10-20-2003, 08:56 PM
My browser warning:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ucbene/public_html/login.php on line 226

In first I think server use old PHP version but the hosting said "IS running PHP 4.3.3". Do you know what wrong with this function?? Please help me...thanks

My code in this file:

$sql="select * from user where username=$un and password=$pss";
$mysql_result=mysql_query($sql,$conn);
$num_rows=mysql_num_rows($mysql_result);

:confused:

Jona
10-20-2003, 09:20 PM
I'm not sure if your second line is a problem or not, since I have never done it that way, but here's how I usually do it...


$db = mysql_connect("localhost","username","password") or die("Could not open connection.". mysql_error());
mysql_select_db("database_name") or die("Could not select database.". mysql_error());

$sql = "SELECT * FROM `user` WHERE `username` = '". $un ."' AND `password` = '". $pss ."'";
$mysql_result = mysql_query($sql);
$num_rows = mysql_num_rows($mysql_result);

mysql_close($db);


[J]ona

snoopy0877
10-21-2003, 02:13 AM
Of course I had define $db and select db seem like your suggest.

That code ran correct in localhost but on the server it's notice that error and my program can not done right. have anyone experience in this case? Help pls...:eek:

Masroor Akhter
10-21-2003, 02:53 AM
its a very simple
PHP 4.3.3 uses the List of Standard Predefiend Variables
You must follow these Predefined Variables to access your
Form/HTML page Variable

You Simply access them as
$un = $_REQUEST['un']; and
$pass = $_REQUEST['un'];

Now you will not resive Server Error

OK

Masroor Akhter
10-21-2003, 03:04 AM
its a very simple
PHP 4.3.3 uses the List of Standard Predefiend Variables
You must follow these Predefined Variables to access your
Form/HTML page Variable

You Simply access them as
$un = $_REQUEST['un']; and
$pass = $_REQUEST['un'];

Now you will not resive Server Error

OK

snoopy0877
10-24-2003, 08:05 PM
Thanks for all help to me. Now, I know what happen on my error. My sql statement call the table is "User" in local host its run correct but in server I must call its is "user"