Re: SQL woes (newbie question) - PHP 4.3.6 & ADOdb

From: Date: Wed, 28 Apr 2004 14:16:14 +0000
Subject: Re: SQL woes (newbie question) - PHP 4.3.6 & ADOdb
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-184876@lists.php.net to get a copy of this message
Torsten Roehr wrote:
"Gabe" <ydnahg-news4432@mailblocks.com> wrote in message news:20040427195929.65268.qmail@pb1.pair.com...
Torsten Roehr wrote:
"Gabe" <ydnahg-news4432@mailblocks.com> wrote in message news:20040427194223.85721.qmail@pb1.pair.com...
I seem to be having some trouble getting my SQL statement to work properly. I'm trying to get it so that I can have any text between the single quotes. So as you can see below, if the text that needs to get updated has a single quote in it, I get an error when trying to execute the statement. The database I'm using is Access, the field type is "memo", and I'm using the ADOdb library. In my example below I'm using a really short string. But in actuality it could be *extrememly* long, and would contain HTML code (thus there would be many single quotes and double quotes). Any ideas so that I can get anything between the single quotes to be seen as text to be updated and not something to be processed? I've tried using double quotes and backticks instead of the single quotes around the text. UPDATE tblFAQ_Question SET fldBody = '<span style='color: #000000;'>hi, what's going on?</span>' WHERE autoQuesID = $intQuestionID;
You have got to escape all quotes BEFORE using it in a query. Take a
look
here: http://de3.php.net/manual/en/function.mysql-real-escape-string.php Regards, Torsten
Thanks! Gabe
Thanks for the link, looks like that will do the trick. But I was also wondering then, when I use a SELECT statement to retrieve the same data and display it, is there a function that will remove all the escape characters? I didn't see anything in the mysql function list.
This should do the trick: http://de3.php.net/manual/en/function.stripslashes.php Regards, Torsten
Hi Torsten, I tried using that function this morning like you suggested, but when I ran it I suddenly realized that I'm running an Access db not a mysql db. The function asks for a resource connection to a mysql db. Is there a similar function that you know of that will do the same thing for an access query? Many thanks! Gabe

« previous php.general (#184876) next »