Jeff VIP
Total posts: 745
23 Jul 2014 18:30

Hi,

I've encountered a very strange but persistent bug in my submission form. Pressing the Save & Close button results in a MySql error, whereas pressing Apply and then Close produces no errors. I have no idea what's going on.

Please help....

Best regards, Jeff

Last Modified: 24 Jul 2014


Sergey
Total posts: 13,748
24 Jul 2014 00:23

Give me access to check or tell what is SQL error?


Jeff VIP
Total posts: 745
24 Jul 2014 01:25
Unknown column '171test' in 'where clause' SQL=SELECT DISTINCT user_id FROM v4on8_js_res_audit_log WHERE record_id = 171test AND event = 6

I think my show donations code is the culprit

//SHOW DONATIONS
//===============

$app = JFactory::getApplication();
if($app->input->get('view') != 'record' && $app->input->get('option') != 'com_cobalt')
{
   // this is not a cobalt article full view. 
   return;
}

$id = $app->input->get('id');
$user = new JsnUser($uid);
$ctime = $app->input->get('ctime');
$sql = "SELECT DISTINCT user_id FROM #__js_res_audit_log WHERE record_id = {$id} AND event = 6";

$db = JFactory::getDbo();
$db->setQuery($sql);
$ids = $db->loadColumn();

if(empty($ids))
{
    echo '';
    return;
}
echo '<div class="uk-panel-box uk-text-center">';
echo '<h3>This notice received donations from</h3>';

foreach($ids as $id) {
    $uid = JFactory::getUser($id)->get('id');
    $user = new JsnUser($uid);
    echo '<a href="'.$user->getLink().'" class="uk-thumbnail" rel="tooltip" data-original-title="'.JFactory::getUser($id)->get('name').$app->input->get('ctime').'">';
    echo JHtml::_('content.prepare','{user avatar_mini '.$id.'}'). '<div class="uk-thumbnail-caption uk-text-small">'.JFactory::getUser($id)->get('name').'</div></a>';
}
echo '</div>';

Sergey
Total posts: 13,748
24 Jul 2014 02:55

Change $id = $app->input->get('id'); to $id = $app->input->getInt('id');;


Jeff VIP
Total posts: 745
24 Jul 2014 03:06

Wheeping like a child behind my computer monitor

+1000

Thank you Sergey!


Sergey
Total posts: 13,748
24 Jul 2014 03:19

To clean up code you can delete first $user = new JsnUser($uid); because theer is no $uid and you do not use it anyway.

And you can change

$uid = JFactory::getUser($id)->get('id');
$user = new JsnUser($uid);

to

$user = new JsnUser($id);

Jeff VIP
Total posts: 745
24 Jul 2014 04:35

Thanks again, Sergey!

Powered by Cobalt