Page 1 of 1

How to insert quotation marks to a mysql db?

Posted: Sun Feb 08, 2009 6:22 pm
by JKM
Hi there!

I was wondering how I could insert quotation marks (") to a mysql db. I want to insert some html codes (<a href="lol.html" target"_blank">lol</a>).

Thanks for any help

Re: How to insert quotation marks to a mysql db?

Posted: Sun Feb 08, 2009 8:00 pm
by califdon
Use the escape (backslash) character.

Re: How to insert quotation marks to a mysql db?

Posted: Sun Feb 08, 2009 8:38 pm
by JKM

Code: Select all

$about = str_replace('"', '\"', nl2br($_POST['about']));
mysql_query("INSERT INTO xxx (about) VALUES ('$about')");
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 'bla bla bla bla blab al' at line 1

Re: How to insert quotation marks to a mysql db?

Posted: Mon Feb 09, 2009 4:33 am
by VladSun
Use mysl_real_escape_string()

Re: How to insert quotation marks to a mysql db?

Posted: Mon Feb 09, 2009 6:53 am
by JKM
Sorry guys, I was too fast with the c/p so there was two quotes in stead of one. :-p