The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> You have an error in your SQL syntax; Logging failed
evbeej
post Jan 18 2016, 06:23 AM
Post #1





Group: Members
Posts: 4
Joined: 18-January 16
Member No.: 23,917



Hello,

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

QUOTE
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 = '81.138.223.98', pageLevel = '', userLevel = '', ' at line 1


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

QUOTE
$sessionCookieExpireTime=8*60*60;

session_set_cookie_params($sessionCookieExpireTime);

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

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

require_once("ugs/class_ugs_client.php");

$ugs = new UGS;

$ugs->addLog(json_encode($_POST),json_encode($_GET),json_encode($_SESSION),$_SERVER['REMOTE_ADDR'],$page_level,json_encode($_SERVER));



any help would really be appreciated.




User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 18 2016, 06:46 AM
Post #2


This is My Life
*******

Group: Members
Posts: 1,437
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
evbeej
post Jan 18 2016, 06:50 AM
Post #3





Group: Members
Posts: 4
Joined: 18-January 16
Member No.: 23,917



Hello, sorry where can i find the addLog code? This is the first time ive come across this sort of thing.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
evbeej
post Jan 18 2016, 07:04 AM
Post #4





Group: Members
Posts: 4
Joined: 18-January 16
Member No.: 23,917



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

QUOTE
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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 18 2016, 07:57 AM
Post #5


This is My Life
*******

Group: Members
Posts: 1,437
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
evbeej
post Jan 18 2016, 09:59 AM
Post #6





Group: Members
Posts: 4
Joined: 18-January 16
Member No.: 23,917



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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th December 2017 - 03:08 PM