paulman888888 Posted December 13, 2008 Share Posted December 13, 2008 Please help me. <?php if(in_array($search_where2,$search_where3)){//check if allowed search if($search_where==$search_allowed[1]){//this works if i search for$search_allowed[1] $query = "SELECT * FROM "; $query.='chess_events'; $query.=" WHERE "; $query.='event_name'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; } }elseif($search_where==$search_allowed[2]){//this doesnt work $query = "SELECT * FROM "; $query.='chess_location'; $query.=" WHERE "; $query.='name'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; }elseif($search_where==$search_allowed[3]){not tested yet $search_table='chess_news'; $search_where4='title'; $query = "SELECT * FROM "; $query.='chess_news'; $query.=" WHERE "; $query.='title'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; }else{echo'Error on Line 129: Error Matching Location to Search';} // Build SQL Query $numresults=mysql_query($query)or exit('Error on Line: 144'); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "Sorry, your search: "" . $trimmed . "" returned zero results"; $search_error=665; echo'Error on Line: 145'; } // next determine if s has been passed to script, if not use 0 if (empty($_REQUEST['s'])) { $s=0; }elseif($_REQUEST['s']>=0){$s=$_REQUEST['s'];}else{$s=0;} // POST results $query .= " LIMIT $s,$limit"; $result = mysql_query($query) or die('Error on Line: 158'); } ?> What have i done wrong? I dont understand# Please Help me Thankyou in advance Paul Hutchinson Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/ Share on other sites More sharing options...
burntheblobs Posted December 13, 2008 Share Posted December 13, 2008 Did wrong how? What exactly is happening? You need to be much more specific. Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714683 Share on other sites More sharing options...
revraz Posted December 13, 2008 Share Posted December 13, 2008 Learn how to have a meaningful subject. Learn how to explain your problem. Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714734 Share on other sites More sharing options...
sKunKbad Posted December 13, 2008 Share Posted December 13, 2008 You should probably write your queries out on one line, because the way you have done it, it can quickly get confusing and messed up. When inside php, your query can have line breaks in it if you need to keep it organized that way. Theres no need to concatenate the query the way you have done it. Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714743 Share on other sites More sharing options...
DarkSuperHero Posted December 13, 2008 Share Posted December 13, 2008 I agree with the above responses...also learn to format your code and indent...it makes it easier to read, and spot errors...get a syntax highlighting editor like ConTEXT, or programers notepad, if at all possible Zend Studio is phenomenal! anyways before your first "elseif" you have an extra } i dont think you meant to have that there....and also one of your comments isnt escaped with //.... anyways here the "fixed" code...hope this helps you solve your issue.... <?php if(in_array($search_where2,$search_where3)){//check if allowed search if($search_where==$search_allowed[1]){ //this works if i search for$search_allowed[1] $query = "SELECT * FROM "; $query.='chess_events'; $query.=" WHERE "; $query.='event_name'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; } elseif($search_where==$search_allowed[2]){//this doesnt work $query = "SELECT * FROM "; $query.='chess_location'; $query.=" WHERE "; $query.='name'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; } elseif($search_where==$search_allowed[3]){//not tested yet $search_table='chess_news'; $search_where4='title'; $query = "SELECT * FROM "; $query.='chess_news'; $query.=" WHERE "; $query.='title'; $query.=" LIKE \"%$trimmed%\" "; $query.=" ORDER BY "; $query.=$order_by; } else{ echo'Error on Line 129: Error Matching Location to Search'; } // Build SQL Query $numresults=mysql_query($query)or exit('Error on Line: 144'); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0){ echo "Sorry, your search: "" . $trimmed . "" returned zero results"; $search_error=665; echo'Error on Line: 145'; } // next determine if s has been passed to script, if not use 0 if (empty($_REQUEST['s'])) { $s=0; } elseif($_REQUEST['s']>=0){ $s=$_REQUEST['s'];}else{$s=0; } // POST results $query .= " LIMIT $s,$limit"; $result = mysql_query($query) or die('Error on Line: 158'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714783 Share on other sites More sharing options...
Mchl Posted December 13, 2008 Share Posted December 13, 2008 anyways before your first "elseif" you have an extra } i dont think you meant to have that there... Maybe he did. There are two if blocks open at that point... but yeah... this might be the reason the next one doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714790 Share on other sites More sharing options...
DarkSuperHero Posted December 13, 2008 Share Posted December 13, 2008 if he did want that one there then he has an extra } at the end of his code.... ...I love Zend Studio its so awesome! found the "mistake" very quickly... Quote Link to comment https://forums.phpfreaks.com/topic/136840-please-for-the-love-of-god-help-me/#findComment-714808 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.