Jump to content

Recommended Posts

hi there i have installed a script and now when i want to accec my site it coms with the next error. what should i do to fix this issue ?

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'\'\', \'195.240.24.221\', \'index.php\', \'GET\', \'20130106052206\', \'0\', \'M' at line 1

Query ::INSERT INTO tracker (id, ip, page, viewType, happened, userID, userAgent, protocol) VALUES ('', '195.240.24.221', 'index.php',
'GET', '20130106052206', '0', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0', 'HTTP/1.0')

Edited by armeen

Let me guess.

 

To save having to escape all the variables individually you created the SQL query and escaped the whole query.

 

try

$sql = sprintf("INSERT INTO tracker (ip, page, viewType, happened, userID, userAgent, protocol)
VALUES ('%s', '%s', '%s', '%s', %d, '%s', '%s')",
mysqli_real_escape_string($connection, $ip),
mysqli_real_escape_string($connection, $page),
mysqli_real_escape_string($connection, $viewType),
mysqli_real_escape_string($connection, $happened),
intval($userID),
mysqli_real_escape_string($connection, $userAgent),
mysqli_real_escape_string($connection, $protocol)
);

 

Note : id is excluded, not passed a blank value

Edited by Barand
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.