Jump to content

[SOLVED] HTTP_USER_AGENT creating invalid query


9three

Recommended Posts

I'm grabbing the user agent from each user and inserting them into a database.

 

Example:

Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6

 

The problem is that user agent separates each line by semicolons so it makes my query not work properly.

 

Any way to fix that?

SQL query:

INSERT INTO user_input (Name, Email, Date, Time, IP, Agent, Message) VALUES (My Name, [email protected], February 14, 2009, 6:05 PM, 127.0.0.1, Mozilla/5.0 (Windows; 

 

This is after sanitizing with mysql_real_escape_string.

 

Also throws an exception, and I figured out it was with the Agent

 

Fatal error: Uncaught exception 'Exception' with message '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 'name, [email protected], February 14, 2009, 6:05 PM, 127.0.0.1, Moz' at line 4' in C:\Users\9three\Desktop\Server\htdocs\gb\library\mysql.class.php:38 Stack trace: #0 C:\Users\9three\Desktop\Server\htdocs\gb\index.php(56): mysql->query('INSERT INTO use...') #1 {main} thrown in C:\Users\9three\Desktop\Server\htdocs\gb\library\mysql.class.php on line 38

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.