In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jtjohnston) wrote:

> > > $where = "id like $id";
<snip>
> So I do?
> 
> $news = mysql_query("select * from ccl where '.$where.' order by AU desc");
> 
> or ?
> 
> $news = mysql_query("select * from ccl where '.%$where%.' order by AU desc");

Neither.  Where $id==1, these would interpolate to:

select * from ccl where '.id like 1.' order by AU desc
select * from ccl where '.%id like 1%.' order by AU desc

This is why <repeat>error checking with an echo of your query to the 
browser</repeat> is valuable.  You can see exactly what the complete query 
string looks like, and also copy/paste it to the commandline for further 
testing.

> The % are not necessary? because id is an auto_increment number from 0 to
> 1,000+.

The "like" keyword is used with a wildcard operator, either "%" or "_".  If 
you're matching against an exact value, then use the "=" operator instead 
of "like".  See the MySQL manual for more info on the "like" keyword and 
wildcards.

If id has a numerical field type instead of one of the string types, you 
don't need to quote $id. See the MySQL manual for more info on quoting 
string values.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to