SQL Syntax error

6 posts by 3 authors in: Forums > CMS Builder
Last Post: December 21, 2022   (RSS)

By pgplast - November 30, 2022

I have started getting an error from a SQL insert in a plugin I wrote:

$query = "INSERT INTO cms__accesslist SET
userNum = '".$user_num."',
tableName = 'all',
accessLevel = '1',
maxRecords   = '',
randomSaveId = '123456789' ";
mysqli()->query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysqli()->error) . "\n");

The error references the need to check for correct syntax around ''" and the randomSaveId value.

Can anyone se ewhat the culprit is? This is the same syntax I use in many other areas.

Thanks.

By pgplast - December 16, 2022

Resolved as mentioned via email.

Thanks.

By gkornbluth - December 16, 2022

Hi,

If you could pass on the actual solution it might be helpful to someone else,

Thanks,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By pgplast - December 17, 2022

For some reason I failed to determine, the syntax I posted earlier didn.t work.

However, using the below instead, did.

mysql_insert('_accesslist', array(
'userNum' => $user_num,
'tableName' => 'apply_for_cme',
'accessLevel' => '6',
'maxRecords' => '1000', // max listings allowed
'randomSaveId' => '123456789', /
));

By gkornbluth - December 21, 2022

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php