You are here: Re: [PHP] Howto search in SQL for a specific character? « PHP « IT news, forums, messages
Re: [PHP] Howto search in SQL for a specific character?

Posted by tg-php on 11/29/05 23:17

Probably because the apostrophe aka single quote is used the same way it and the double quotes (") are used in PHP, as a string delimiter.

What you're ending up with is:

SELECT nameOfPedigree FROM tbpedigrees WHERE SUBSTR(nameOfPedigree,0,1) = '

What you'd want is something more like:

SELECT nameOfPedigree FROM tbpedigrees WHERE SUBSTR(nameOfPedigree,0,1) = "'"

So maybe try this:

$sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE SUBSTR(nameOfPedigree,0,1) = \"$v1\"";

See if that works any better.

-TG





= = = Original message = = =

Hi there!

in PHP i Write..


$v1 = chr(39); //39 is apostrofe


$sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE
SUBSTR(nameOfPedigree,0,1) = $v1";

Why doesn't this work?

I want the sql to select all nameOfPedigree - fields where the first
character is apostrofe (')

/G
http://www.varupiraten.se/


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация