Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Databases _ You have an error in your SQL syntax; Logging failed

Posted by: evbeej Jan 18 2016, 06:23 AM


I have received the following error on two of our sites (that are on the same server)

Logging failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'get = '[]', session='[]', ip = '', pageLevel = '', userLevel = '', ' at line 1

the following is where i think it is saying the problem is...:



if (!$_SESSION) { session_start(); }

if ($_GET['a'] == "logout" || $logout == "logout") { session_destroy(); }


$ugs = new UGS;


any help would really be appreciated.

Posted by: CharlesEF Jan 18 2016, 06:46 AM

Without seeing the addLog code from the class I don't think you have provided enough information. Are you sure you have provided the correct number of arguments for the call?

Posted by: evbeej Jan 18 2016, 06:50 AM

Hello, sorry where can i find the addLog code? This is the first time ive come across this sort of thing.

Posted by: evbeej Jan 18 2016, 07:04 AM

Ok, it looks like the following function is what is causing the error... :

function addLog($post,$get,$sess,$ip,$pageLevel=0,$server=0) {

mysql_query("INSERT INTO logs SET post='".mysql_real_escape_string($post)."', get = '".mysql_real_escape_string($get)."', session='".mysql_real_escape_string ($sess)."', ip = '{$ip}', pageLevel = '{$pageLevel}', userLevel = '{$_SESSION['role']}', userid = '{$_SESSION['uuid']}', sessionid = '".session_id()."', url = '".mysql_real_escape_string($_SERVER['REQUEST_URI'])."', server='".mysql_real_escape_string($server)."'",$this->db) or die("Logging failed".mysql_error());

So i am going to investigate this a bit further. As it was not where i thought it was at all.

Posted by: CharlesEF Jan 18 2016, 07:57 AM

Nothing jumps out at me except that you are still using mysql_* functions. mysql_* functions have been removed in PHP v7 and if you ever upgrade to that version your code will no longer work. All your code will have to be rewritten to use mysqli_* or PDO functions.

Posted by: evbeej Jan 18 2016, 09:59 AM

I think that may be it, all i know is i commented out that query and both sites now show the sites correctly.

Powered by Invision Power Board (
© Invision Power Services (