Jump to content

[SOLVED] mysql_num_rows Argument is not valid


otuatail

Recommended Posts

Hi I am finding this a bit confusing as it should be valid.

 

<?
include ("../MalawiFunctions.inc");
$page = "Topic";
session_start();
connectDB(3);
$USR = $_POST['User'];
$PWD = $_POST['pwd'];
$sql = "SELECT * FROM Accounts WHERE USR = '" . $USR . "' AND PWD = '" . $PWD . "'";

$query = mysql_query($sql); // or die(mysql_error());
$Rows = mysql_num_rows($query);
?>

 

I get

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fhlinux190/d/des-otoole.co.uk/user/htdocs/cms/admin/Validate.php on line 11

11 = $Rows = mysql_num_rows($query); but this should be valid

 

Change this line:

 

$query = mysql_query($sql); // or die(mysql_error());

 

to this:

 

$query = mysql_query($sql) or die(mysql_error());

 

To see what is wrong with the query that it is not acting fine for the num_rows.

Everytime if you see your num_rows gives you such error, Check your query.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.