You are here: Re: New to PHP - Search Question « PHP Programming Language « IT news, forums, messages
Re: New to PHP - Search Question

Posted by JDS on 10/22/01 11:25

On Tue, 30 Aug 2005 02:45:54 -0700, Alec wrote:

> Problem solved with ('SELECT name FROM site01_details WHERE town
> LIKE "Bury"');

Your SQL statement should:

* use single quotes around the value after LIKE
http://dev.mysql.com/doc/mysql/en/string-syntax.html

* There really is no reason to use LIKE if you do not use wildcards -- the
percent sign "%". Use equals "=" instead

Your SQL statement should look like:

$sql_statement = "SELECT name FROM site01_details WHERE town = 'Bury'";

You are best off putting the SQL statment in a variable and putting the
variable into the mysql_query() function:

$result = mysql_query($sql_statement);

(I don't know why some books don't do this straight away, or at all. It
doesn't make sense to me to teach something one way and then un-teach it
later.)

I have other comments on coding style and whatnot but this is enough for
now, I imagine.

COWS

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

 

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

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