Hi there, most interesting forum and I hope I can get some help here.
I have 2 record sets, one which looks up a product by SKU and the table contains a field with "related SKU's" in a comma separated text field.
I have created a Var with the "related SKU's" field and need to do a second query where I get all the related products. So far I have been unsuccessful using the "implode" function and just cannot get it to work, I keep getting all sorts of errors.
The query I am using is as follows:
RecProd=$row_Rs_recProd['PR_UpSales']; $colname_RsShowItem = $RecProd; } mysql_select_db($database_Conn_PDG, $Conn_PDG); $query_RsShowItem = sprintf("SELECT * FROM PRODUCTS WHERE PR_SKU in %s and PRODUCTS.PR_IsInactive=0", GetSQLValueString($colname_RsShowItem, "text")); $RsShowItem = mysql_query($query_RsShowItem, $Conn_PDG) or die(mysql_error()); $row_RsShowItem = mysql_fetch_assoc($RsShowItem); $totalRows_RsShowItem = mysql_num_rows($RsShowItem);
As it stands, the above gives me the error:
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 ''PROF,45,48,49,4,3,11' and PRODUCTS.PR_IsInactive=0' at line 1
The variable $RecProd returns a comma separated list like: PROF,45,48,49,4,3,11 which are the related product's SKU, which I need returned.
I did see some other examples of such queries, but if I use the code:
$RecProd=$row_Rs_recProd['PR_UpSales']; $RecProd= implode("','", $RecProd);
I get an error:
Warning: implode() [function.implode]: Invalid arguments passed in recommended-items.php on line 49 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 'NULL and PRODUCTS.PR_IsInactive=0' at line 1
Any help with this would be most welcome.