RE: [PHP] Howto search in SQL for a specific character?
| From: | Jay Blanchard | Date: | Tue, 29 Nov 2005 20:59:40 +0000 |
| Subject: | RE: [PHP] Howto search in SQL for a specific character? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-226600@lists.php.net to get a copy of this message | ||
[snip]
$v1 = chr(39); //39 is apostrofe
$sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE
SUBSTR(nameOfPedigree,0,1) = $v1";
Why doesn't this work?
[/snip]
Probably because the character set is misinterpreted. What happens when you
echo $v1? Try
$sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE
SUBSTR(nameOfPedigree,0,1) = ''' ";