RE: [PHP] WHERE problem
| From: | Brad Fuller | Date: | Mon, 19 Feb 2007 21:10:34 +0000 |
| Subject: | RE: [PHP] WHERE problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249050@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Mike Shanley [mailto:thebarmy@omniversalism.com]
> Sent: Monday, February 19, 2007 3:50 PM
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] WHERE problem
>
> Without the single-quotes, I still get nothing returned.
>
> Bruce Cowin wrote:
> > Are you getting an error or just nothing returned? The first thing I'd
> check is if index is a numeric field and if it is, remove the single
> quotes from around $randi in the where clause.
> >
Two things that come to mind...
1) If there are 100 records in there, is the value of the 'index' column
exactly 1-100? It won't do any good to give it a random value of 1-100 if
your records are numbered 101-200 :P
2) INDEX is a mysql keyword. Try putting backticks around it.
"... WHERE
index = $randi"
If all else fails, remove the part of your code that generates the random
'index' and just use "ORDER BY RAND() LIMIT 1" in your query.
HTH,
Brad