Jump to content

after installation of a script mysql error


armeen

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')

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.