php - SQL syntax error when selecting from tables in Joomla 2.5 -
i error:
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'from
lg3ni_k2_favorites
faves,lg3ni_k2_items
items, (faves.user' @ line 1 sql=select faves.item_id item_id, items.title items_name,lg3ni_k2_favorites
faves,lg3ni_k2_items
items, (faves.user_id='349') , (faves.item_id = items.id)
from syntax:
$db =& jfactory::getdbo(); $query = "select faves.item_id item_id, items.title items_name, "; $query .= "from `#__k2_favorites` faves, `#__k2_items` items, "; $query .= "where (faves.user_id='".intval($userid)."') "; $query .= "and (faves.item_id = items.id) "; $db->setquery($query); $ff = $db->loadobjectlist(); echo $db->geterrormsg(); return $ff;
where problem?
you have comma after items_name,
,another comma after as items
$query = "select faves.item_id item_id, items.title items_name "; $query .= "from `#__k2_favorites` faves, `#__k2_items` items ";
Comments
Post a Comment