PHP Classes

mysql_num_rows error

Recommend this page to a friend!

      Quick CSV import  >  All threads  >  mysql_num_rows error  >  (Un) Subscribe thread alerts  
Subject:mysql_num_rows error
Summary:Warning: mysql_num_rows(): supplied argument is not a valid MySQ
Messages:4
Author:Thukbir Makhani
Date:2006-09-25 18:24:10
Update:2008-01-03 21:06:53
 

  1. mysql_num_rows error   Reply   Report abuse  
Picture of Thukbir Makhani Thukbir Makhani - 2006-09-25 18:24:10
Why am I getting the following warning:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/teammi4/public_html/quick/Quick_CSV_import.php on line 136


Line 136 in Quick_CSV_import.php has:

if(mysql_num_rows($res) > 0)

Line 134-135 has:

$sql = "SHOW CHARACTER SET";
$res = @mysql_query($sql);

Thank you

  2. Re: mysql_num_rows error   Reply   Report abuse  
Picture of Joshua Joshua - 2006-10-28 17:12:48 - In reply to message 1 from Thukbir Makhani
I'm getting the same error. Anyone have suggestions?

  3. Re: mysql_num_rows error   Reply   Report abuse  
Picture of Alexander Skakunov Alexander Skakunov - 2006-10-28 18:15:44 - In reply to message 1 from Thukbir Makhani
What version of MySQL do you have?

As it's told at manual reference (http://dev.mysql.com/doc/refman/4.1/en/show-character-set.html):
"SHOW CHARACTER SET is available as of MySQL 4.1.0"

Alex.

  4. Re: mysql_num_rows error   Reply   Report abuse  
Picture of asher asher - 2008-01-03 21:06:01 - In reply to message 1 from Thukbir Makhani
hai

im a begineer im stuck in this error for the past 3 hrs pls help
mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\index.php on line 28


asher


-------------------------------------------------------------------------------
<?php
session_start();


session_destroy();

$message="";


$Login=$_POST['Login'];
if($Login){
$username=$_POST['username'];
$md5_password=md5($_POST['password']);


$host="localhost";
$db_user="root";
$db_password="";
$database="tutorial";
$db=mysql_connect($host,$db_user);
mysql_select_db($database,$db);

// Check matching of username and password.
$srch="select * from admin where username='$username' and password='$md5_password'";
$result=mysql_query($srch,$db);

$num_rows = mysql_num_rows($result);

if($num_rows!='0') { // If match.
session_register("username"); // Craete session username.
header("location:main.php"); // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}

} // End Login authorize check.
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php echo $message; ?>
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
<table>
<tr>
<td>User : </td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
<input name="Login" type="submit" id="Login" value="Login" />
</form>
</body>
</html>