Jump to content

[SOLVED] search string error


ccrevcypsys

Recommended Posts

so i get this error whenever i try to search for certain things on my product page.

MySQL Error Occured
n1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN cc_StreamRush_customer on cc_StreamRush_customer.customer_id=cc_Strea' at line 1
n

QUERY = SELECT * FROM cc_St eamRush_i ve to y INNER JOIN cc_St eamRush_catego y o cc_St eamRush_i ve to y.cat_id = cc_St eamRush_catego y.cat_id INNER JOIN cc_poi ts o so gid=cc_St eamRush_i ve to y.p oductId WHERE ( ame LIKE '%s%' OR desc iptio LIKE '%s%' OR p oductCode LIKE '%s%') LEFT JOIN cc_St eamRush_custome o cc_St eamRush_custome .custome _id=cc_St eamRush_i ve to y.custome _id ORDER BY ame ASC
n

I know it cuts out the r's, n's

 

Here is the code from the page

if(!isset($_GET['mode'])){

// make sql query
if(isset($_GET['edit']) && $_GET['edit']>0){

	$query = sprintf("SELECT * FROM ".$glob['dbprefix']."StreamRush_inventory WHERE productId = %s", $db->mySQLSafe($_GET['edit'])); 

} else {

	if(isset($_GET['orderCol']) && isset($_GET['orderDir'])){

		$orderBy = " ".$_GET['orderCol']." ".$_GET['orderDir'];

	} else {

		$orderBy = $glob['dbprefix']."StreamRush_inventory.productId ASC";

	}

	$whereClause = "";

	if(isset($_GET['searchStr']) && !empty($_GET['searchStr'])){
		$searchwords = split ( "[ ,]", $_GET['searchStr']);   

	foreach($searchwords as $word){
		$searchArray[]=$word;
	}

	$noKeys = count($searchArray);
	for ($i=0; $i<$noKeys;$i++) {

		$ucSearchTerm = strtoupper($searchArray[$i]);
		if(($ucSearchTerm!=="AND")AND($ucSearchTerm!=="OR")){

			$like .= "(name LIKE '%".$searchArray[$i]."%' OR description LIKE '%".$searchArray[$i]."%' OR  productCode LIKE '%".$searchArray[$i]."%') OR ";

		} else {
			$like = substr($like,0,strlen($like)-3);
			$like .= $ucSearchTerm;
		}  

	}
	$like = substr($like,0,strlen($like)-3);

	$whereClause .= "WHERE ".$like;

}


if(isset($_GET['category']) && $_GET['category']>0){

	if(isset($like)){
		$whereClause .= " AND ";
	} else {
		$whereClause .= " WHERE ";
	}

	$whereClause .= $glob['dbprefix']."StreamRush_inventory.cat_id = ".$_GET['category']; 

}


	$query = "SELECT * FROM ".$glob['dbprefix']."StreamRush_inventory INNER JOIN ".$glob['dbprefix']."StreamRush_category on ".$glob['dbprefix']."StreamRush_inventory.cat_id = ".$glob['dbprefix']."StreamRush_category.cat_id INNER JOIN cc_points on songid=".$glob['dbprefix']."StreamRush_inventory.productId ".$whereClause." LEFT JOIN ".$glob['dbprefix']."StreamRush_customer on  ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."StreamRush_inventory.customer_id ORDER BY ".$orderBy;

} 

// query database
if(isset($_GET['page'])){
	$page = $_GET['page'];
} else {
	$page = 0;
}

$results = $db->select($query, $productsPerPage, $page);
$numrows = $db->numrows($query);
$pagination = $db->paginate($numrows, $productsPerPage, $page, "page");
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.