PHP fetch category stopped working in 2.1.4

Hello,

I have a php script that generates a datafeed.

When i’ve upgraded from 2.0.14 to 2.1.4 it stopped working.

It seems that the category field isn’t extracted correctly.



This is the error i am getting:



Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in … on line 86



Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in … on line 100




<br />
// Get all categories<br />
$res_cat = db_query("SELECT ?:categories.category_id, ?:categories.parent_id, ?:category_descriptions.category, ?:seo_names.name AS seo_name  <br />
FROM ?:categories<br />
LEFT JOIN ?:category_descriptions ON ( ?:category_descriptions.category_id = ?:categories.category_id ) <br />
LEFT JOIN ?:seo_names ON (?:categories.category_id = ?:seo_names.object_id AND type = 'c')<br />
WHERE ?:category_descriptions.lang_code = '" . $lang_code . "'");<br />
<br />
[86] while ($row_cat = mysql_fetch_assoc($res_cat)) {<br />
	if ($row_cat['parent_id'] > 0) {<br />
		$CAT_ARR[$row_cat['category_id']]['name'] = $CAT_ARR[$row_cat['parent_id']]['name'] . " > " . $row_cat['category'];<br />
		$CAT_ARR[$row_cat['category_id']]['seo_name'] = $CAT_ARR[$row_cat['parent_id']]['seo_name'] . "/" . $row_cat['seo_name'];	<br />
	}<br />
	else {<br />
		$CAT_ARR[$row_cat['category_id']]['name'] = $row_cat['category'];<br />
		$CAT_ARR[$row_cat['category_id']]['seo_name'] = $row_cat['seo_name'];<br />
	}<br />
}<br />
<br />
// Get SEO settings<br />
$res_cat = db_query("SELECT options <br />
FROM ?:addons WHERE addon = 'seo'");<br />
[100] while ($field_seo = mysql_fetch_assoc($res_cat)) {<br />
	if(strpos($field_seo['options'], "product_category")) {<br />
		$seo_type = "product_category";<br />
	}<br />
	else {<br />
		$seo_type = "product_file";<br />
	}<br />
}<br />

```<br />
<br />
<br />
This script worked flawlessly with 2.0.14.<br />
Probably something changed in the cs-cart database.<br />
<br />
If anyone could help me it would be really great.<br />
<br />
Thank you,<br />
Mircea

Your query is failing and you’re not detecting why.

Add error checking and you’ll probably see that a field is no longer there or has changed type.



It appears that you are mixing cs-cart DB syntax (I.e. ?:slight_smile: with using standard mysql. Mysql is probably balking at the ?:table_name syntax you are using. Suggest you use the internal database functions rather than mysql directly.