Actually, I think the more appropriate fix for this problem, would be to do
what a call to mysql_escape_string does.

The problem occuring is common, the characters being used are taken
literally as part of the string, rather than as quotes what you want them
as.  MySQL's C library has the function mysql_escape_string which takes
various characters like single and double quotes, and turns them into their
binary equivilents, so they are interpreted correctly, and not as part of
the string termination.

Example:

SELECT * FROM Users WHERE Username='%s';
Where %s is "Test's", without quotes, will produce an error.  The single
quote in Test's will end the string which is matching against Username,
which in effect has just botched your SQL statement.

The mysql_escape_string will turn the string "Test's" into something like
"Test\027s" which will be parsed correctly in the SQL statement itself.

Hope this helps,
    -Shane

----- Original Message ----- 
From: "Becoming Digital" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 2:08 AM
Subject: Re: Apstrophee Errors


> If you're using PHP, format the result with addslashes().  This will
escape-out
> any quotes in the string.
>
> Edward Dudlik
> Becoming Digital
> www.becomingdigital.com
>
>
> ----- Original Message -----
> From: "Weston Skeans" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, 15 June, 2003 13:47
> Subject: Apstrophee Errors
>
>
> I am using mmysql 3.23.41 and am having querrying problems. I am using my
> database to organize music. Whenever I query my database for a album with
an
> apostrophee in it, It returns no results this is my sintax:
>
> select * from lyric where album like '%Blind Man\'s Zoo%';
>
> I am trying to find songs from 10,000 Maniac's "Blind Man's Zoo" I have
> checked the database and all the songs are listed under the album "Blind
> Man\'s Zoo". All other queries work fine as long as there aren't any
> apostrophees. Any help?
>
> -Weston
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
>
>
>
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to