Jump to content

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

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.