Reputation: 729
The Joomla (3.3) Jdatabase code below (used by Fabrik) is supposed to find a name in the database. The name is submitted in a form (var $data) and has value 'green'.
However, when executing the code I get the error message:
1054 - Unknown column 'green' in 'where clause' SQL=SELECT `user_id` FROM `weq_extendedreg_users` WHERE `cf_collectivename` = `green`
Joomla php code:
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName('user_id'));
$query->from($db->quoteName('#__extendedreg_users'));
$query->where($db->quoteName('cf_collectivename') . ' = '. $db->quoteName($data)); //use $data for this form element
$db->setQuery($query);
$db->execute();
$collective_id = $db->loadResult(); //query returns null if fails
//var_dump($data,$collective_id);exit;
return isset($collective_id);
I dont understand what is wrong with the where statement and why 'the code thinks' the form variable is a table column? (I checked http://docs.joomla.org/Selecting_data_using_JDatabase )
Any ideas?
Upvotes: 1
Views: 303