Jump to content

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


iceblox

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
?>

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.