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... Quote 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"); Quote 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? Quote 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 ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.