ccrevcypsys Posted October 3, 2007 Share Posted October 3, 2007 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"); } Quote Link to comment https://forums.phpfreaks.com/topic/71715-solved-search-string-error/ Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 I know it cuts out the r's, n's Um, that's your problem. Quote Link to comment https://forums.phpfreaks.com/topic/71715-solved-search-string-error/#findComment-361095 Share on other sites More sharing options...
ccrevcypsys Posted October 3, 2007 Author Share Posted October 3, 2007 I know it cuts out the r's, n's Um, that's your problem. thats not wat i was asking about... i was just simply stating that. Quote Link to comment https://forums.phpfreaks.com/topic/71715-solved-search-string-error/#findComment-361102 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Oh, you've got a LEFT JOIN after your WHERE clause Quote Link to comment https://forums.phpfreaks.com/topic/71715-solved-search-string-error/#findComment-361103 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.