Re: Apostrophe's
| From: | David Robley | Date: | Thu, 10 Aug 2000 06:17:48 +0000 |
| Subject: | Re: Apostrophe's | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11071@lists.php.net to get a copy of this message | ||
On 10 Aug, Mike Tuller wrote:
> I've looked at every document I can find in books and on the web, and still
> can't seem to solve this problem. Here is what I have.
>
> $Learned3 = mysql_query ("SELECT count(*) from cs_studentsurvey where
> LearnedSchoolProgram='I didn't learn very much'");
> $Learned3results = mysql_fetch_row( $Learned3 );
> print( $Learned3results[0] );
>
> and I am getting this error.
>
> Warning: 0 is not a MySQL result index in ../count.php3 on line 134
>
> The problem seems to be with the apostrophe. I've looked up stripslashes(),
> but can't find any documentation that will actually tell me how to use it.
>
Your problem in this particular instance needs addslashes. Something
like:
$value = addslashes("I didn't learn very much");
and then your query would be
"SELECT count(*) from cs_studentsurvey where LearnedSchoolProgram='$value'"
Also look at the config settings magic_quotes_runtime and
magic_quotes_gpc
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA