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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.