iceblox Posted June 7, 2007 Share Posted June 7, 2007 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... Link to comment https://forums.phpfreaks.com/topic/54585-solved-help-with-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql/ Share on other sites More sharing options...
jaikar Posted June 7, 2007 Share Posted June 7, 2007 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"); Link to comment https://forums.phpfreaks.com/topic/54585-solved-help-with-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql/#findComment-269910 Share on other sites More sharing options...
iceblox Posted June 7, 2007 Author Share Posted June 7, 2007 sorry to be blonde but where would i insert that within my script? and would that replace num rows? Link to comment https://forums.phpfreaks.com/topic/54585-solved-help-with-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql/#findComment-269919 Share on other sites More sharing options...
sayedsohail Posted June 7, 2007 Share Posted June 7, 2007 <?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 ?> Link to comment https://forums.phpfreaks.com/topic/54585-solved-help-with-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql/#findComment-269954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.