You are here: single quotes and saving to mysql « PHP Language « IT news, forums, messages
single quotes and saving to mysql

Posted by misiek on 04/16/07 22:18

Problem with saving a text with a single quote.
I have the magic_quotes_gpc on in PHP
and get_magic_quotes_gpc() return true. But php still adding backslash
before single quote, when I refresh a site it adds two more.

Basicly I cannot save a text do DB.

I am just reading this site
http://www.php-mysql-tutorial.com/mysql-php-guestbook.php
and found info but is not really helpful because is not working for me


"
Sometimes a message can contain single quotes, we need to escape these
single quotes ( replacing it with \' ) otherwise MySQL will think that
it's the end of a string and the query will fail. We use the
addslashes() function to escape the string.

Unfortunately some web hosts set the magic_quotes_gpc setting on. This
will make values containing single-quotes in $_GET, $_POST and $_COOKIE
will be automatically escaped. If we use addslashes() when the string is
already escaped the result would be a mess.

To check if magic_quotes_gpc is On use get_magic_quotes_gpc(). If it
returns true then we don't have to call addslashes().
"

it sound like I should be good because the function add a backslash
before single quote so why I cannot save to database ?

What I can do about that ?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация