Jump to content

Why isnt it getting down to the bottom of the function


bradmasterx

Recommended Posts

It dosent get down to the bottom ? i even tried echo'ing the $SQL varible inside the query function but just nothing.

 

No errors are given but the query does not take place.

 

	function runSearch (DBConnection $DB ,$keyword=false, $partno=false, $manufacturer=false, $Start=0, $Limit=30){
	$SQL = "SELECT * FROM `turbodata`";
	if(!empty($keyword)){
		$peices = explode(" ", $keyword);
		$HowManyKeywords = count($peices);
		if($HowManyKeywords == 1){
			$SQL .= " WHERE `make` LIKE '%$keyword%' ";
			$SQL .= "|| `model` LIKE '%$keyword%' ";
			$SQL .= "|| `engine` LIKE '%$keyword%' ";
			$SQL .= "|| `enginecode` LIKE '%$keyword%'";
			$SQL .= "|| `year` LIKE '%$keyword%' ";
			$SQL .= "|| `turbotype` LIKE '%$keyword%' ";
			$SQL .= "|| `partno` LIKE '%$keyword%' ";
			$SQL .= "|| `dashnumbers` LIKE '%$keyword%' "; 
			$SQL .= "|| `oem` LIKE '%$keyword%' ";
			$SQL .= "|| `oem2` LIKE '%$keyword%' ";
			$SQL .= "|| `oem3` LIKE '%$keyword%' ";
			$SQL .= "|| `oem4` LIKE '%$keyword%' ";
			$SQL .= "|| `oem5` LIKE '%$keyword%' ";
			$SQL .= "|| `oem6` LIKE '%$keyword%'";
		}elseif($HowManyWords > 1){
			for($a=0;$a<$HowManyKeywords;$a++) {
				$SQL = " WHERE `make` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `model` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `engine` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `enginecode` LIKE '%$pieces[$a]%'";
				$SQL .= "|| `year` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `turbotype` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `partno` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `dashnumbers` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem2` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem3` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem4` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem5` LIKE '%$pieces[$a]%' ";
				$SQL .= "|| `oem6` LIKE '%$pieces[$a]%'";
			}
		}
		if(!empty($partno)){
			if(!strstr($SQL, "WHERE")){
				$SQL  .= " WHERE `partno` LIKE '$partno%'";
			}
			else{
				$SQL .= " && `partno` LIKE '$partno%'";
			}
		}
		if(!empty($manufacturer)){
			if(!strstr($SQL, "WHERE")){
				$SQL .= " WHERE `make` LIKE '$manufacturer'";
			}
			else{
				$SQL .= " && `make` LIKE '$manufacturer'";
			}
		}
		$SQL .= " LIMIT {$Start},{$Limit}";
		return $DB->query($SQL);
	}
}

A) How are you calling the function? Are you sure you are providing it with data that would cause it to take an execution path that executes the query?, and

B) Are you developing and debugging your php code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the errors php detects will be reported and displayed?

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.