Re: mysql escape character \'

From: Date: Tue, 07 Aug 2001 17:14:27 +0000
Subject: Re: mysql escape character \'
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61664@lists.php.net to get a copy of this message
Rasmus, solved this problem for me earlier today. Hope this helps Rasmus, Thank you very much. I ended up using the following statement, and it works!! > $results=mysql_query(stripslashes($sql_statement)); What I have now is a textarea box where I can input trial searches. This is why I'm dealing with the whole sql statement. With time, I plan on passing only the variables. Thanks again. Hugh ----- Original Message ----- From: Rasmus Lerdorf <rasmus@php.net> To: Hugh Danaher <hdanaher@earthlink.net> Cc: <php-general@lists.php.net> Sent: Wednesday, July 18, 2001 1:49 AM Subject: Re: [PHP] help on getting rid of \' > > I am working with php and mysql and have the need to write a query like: > > > > $sql_statement=mysql_query(" select * from table where column='string' "); > > > > What comes out is: > > > > select * from table where column=\'string\' > > Only if you pass that variable through a GET/POST/COOKIE operation and you > have magic_quotes_gpc enabled in your php.ini file. Either turn > magic_quotes off or call stripslashes() on your string before passing it > to MySQL. > > But, are you sure you want to be passing entire query strings between > pages? Normally you would only pass the actual query arguments. In your > case probably the 'string' part. > > -Rasmus > ----- Original Message ----- From: hassan el forkani <webmaster@warmafrica.com> To: <php-general@lists.php.net> Cc: <mysql@lists.mysql.com> Sent: Tuesday, August 07, 2001 7:32 AM Subject: [PHP] mysql escape character \' > greetings; > > i'm not sure if this is a mysql or php issue so i'm posting to both lists, > > i'm developping a community web site with news, forums......; > while working on the admin section i noticed this behaviour: > > on my hosting platform (linux) > i need to replace single quotes by \' to properly insert the data into the > database and avoid errors > on my dev machine (win98) there is no need to do so as single quotes are > properly inserted and attempting to escape them actually inserts \' instead > of '; > > so the same code does not have the same output on windows and linux > > can someone explain?? > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#61664) next »