Jump to content

[SOLVED] Help with "Warning: mysql_num_rows(): supplied argument is not a valid MySQL "


Recommended Posts

Hi Guys having some issues with this error. It only comes up when i go direct to the page, i know why its happening thats cos the scripts WHERE clauses use POST. So when i go direct to the page it has nothing to post. Is there anyway to stop this.

 

Here is the script...

 

 

<?php

$query = "SELECT * FROM test WHERE area_id='$_POST[area_id]' AND beds>'$_POST[beds]' AND price BETWEEN $_POST[min] AND $_POST[max] ORDER BY $_POST[s]";

$result = mysql_query($query);

if (mysql_num_rows($result) > 0)
{

while($row = mysql_fetch_row($result))
{

echo'' . $row[1] . ' ' . $row[2] . ' ' . $row[3] . '<br>';

}

}
else
{
echo 'No rows found!';
}

?>

 

Any help would be appreacited...

may be you can try this

 

if(!$_POST['submit') {

 

    echo " some warnig message,";

 

exit; 

}

 

OR

 

if(count($_POST) == 0) {

exit;

 

}

 

you can echo something or redirect the page like header("Location:someurl");

<?php 

if(!$_POST['submit') {

    echo " some warnig message,";
   
exit;   
} 
else
{
$query = "SELECT * FROM test WHERE area_id='$_POST[area_id]' AND beds>'$_POST[beds]' AND price BETWEEN $_POST[min] AND $_POST[max] ORDER BY $_POST[s]";

$result = mysql_query($query);

if (mysql_num_rows($result) > 0)
{

while($row = mysql_fetch_row($result))
{

echo'' . $row[1] . ' ' . $row[2] . ' ' . $row[3] . '<br>';

}

}
else
{
echo 'No rows found!';
}


} //end of issubmit
?>

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.