DonJuma
DonJuma

Reputation: 2094

Put semicolon in sql

I would like to know if i can put a semicolon in a SQL table. Or would that mess things up like an injection attack. Basically what I'm trying to put in is my HTTP_USER_AGENT info and that includes a semicolon. Or Basically there a way i can turn that semicolon into the html symbol for it? Thank You So Much

Upvotes: 0

Views: 422

Answers (2)

middus
middus

Reputation: 9121

Yes, you can put a semicolon in a mySQL table. Even more: You can put anything into it as long as it is escaped properly.

However, I'd heavily recommend using prepared statements that will do the escaping for you. My first preference is PDO but you can also check out MySQLi.

Upvotes: 4

Hendrik Brummermann
Hendrik Brummermann

Reputation: 8312

Use mysql_real_escape_string, it will do all the escaping work for you, you just have to put ' before and after it.

mysql_real_escape_string($_SERVER['HTTP_USER_AGENT'])

Upvotes: -1

Related Questions