Re: How do I get PHP to save a backslash in a Mysql table?

From: Date: Wed, 10 Oct 2007 18:12:34 +0000
Subject: Re: How do I get PHP to save a backslash in a Mysql table?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-263053@lists.php.net to get a copy of this message
On 10/10/07, Don Proshetsky <don@program-it.ca> wrote: > > Hi, > > I have a field in which a user inputs a Windows style directory path, > hence > using backslashes and not forward slashes. > > Example: c:\qb\data\mydatadile.qbw > > However, when the use clicks update, what gets saved is: > c:qbdatamydatadile.qbw > > Does anyone know if there is a work around? > > The backslashes mysteriously are stripped. I use the following function > to > wrap each variable that's saved in the MySQL table: > > function update_database($value) > { > // Addslashes > if (!(get_magic_quotes_gpc())) { > $value = addslashes($value); > } > // Quote if not a number or a numeric string > if (!is_numeric($value)) { > $value = mysql_real_escape_string($value); > } > return $value; > } most likely neither of the conditions in the function is getting hit and mysql is removing the \ characters from the original string. try echoing out $value before the update to see if it is what you expect. -nathan

« previous php.general (#263053) next »