iceblox Posted October 27, 2007 Share Posted October 27, 2007 Hi Everyone, Ive been working on this new site and the form page has about 7 different drop downs on it and they all go to the same results page so my Query looks abit tricky. I thought i had it but i keep getting an error. The error is Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/yoursite.com/httpdocs/mobile-phone-deals/deals_new.php on line 13 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/yoursite.com/httpdocs/mobile-phone-deals/deals_new.php on line 137 and this is the result page query $query = "SELECT * FROM deals WHERE NetworkName = '$_POST[NetworkName]' AND PhoneCost BETWEEN 0 AND '$_POST[PhoneCost]' AND ContractLength BETWEEN 0 AND '$_POST[ContractLength]' AND FreeMins BETWEEN '$_POST[FreeMins]' AND 9999 AND FreeTexts BETWEEN '$_POST[FreeTexts]' AND 9999"; $result = mysql_query($query); Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/75018-mysql-php-form-query-not-working/ Share on other sites More sharing options...
MadTechie Posted October 27, 2007 Share Posted October 27, 2007 try this <?php $query = "SELECT * FROM deals WHERE NetworkName = '{$_POST['NetworkName']}' AND PhoneCost BETWEEN 0 AND '{$_POST['PhoneCost']}' AND ContractLength BETWEEN 0 AND '{$_POST['ContractLength']}' AND FreeMins BETWEEN '{$_POST['FreeMins']}' AND 9999 AND FreeTexts BETWEEN '{$_POST['FreeTexts']}' AND 9999"; $result = mysql_query($query) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75018-mysql-php-form-query-not-working/#findComment-379320 Share on other sites More sharing options...
iceblox Posted October 27, 2007 Author Share Posted October 27, 2007 Thanks MADTechie used that code and found the error. Missed typed one of the columns! LoL Can i ask you one other thing in my drop down it gives me the option to select "ANY" so lets say Network they can either specify the network or view the deals from all the networks how would this be coded in? Quote Link to comment https://forums.phpfreaks.com/topic/75018-mysql-php-form-query-not-working/#findComment-379327 Share on other sites More sharing options...
MadTechie Posted October 29, 2007 Share Posted October 29, 2007 i would probably code it like this <?php $network = ($_POST['NetworkName'] != "Any")?"NetworkName = '{$_POST['NetworkName']}' AND ":""; $query = "SELECT * FROM deals WHERE $network PhoneCost BETWEEN 0 AND '{$_POST['PhoneCost']}' AND ContractLength BETWEEN 0 AND '{$_POST['ContractLength']}' AND FreeMins BETWEEN '{$_POST['FreeMins']}' AND 9999 AND FreeTexts BETWEEN '{$_POST['FreeTexts']}' AND 9999"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75018-mysql-php-form-query-not-working/#findComment-380081 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.