#22597 [Com]: PHP can't select random rows from MySql
| From: | genius at airmail dot net | Date: | Thu, 13 Mar 2003 03:12:38 +0000 |
| Subject: | #22597 [Com]: PHP can't select random rows from MySql | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-35480@lists.php.net to get a copy of this message | ||
ID: 22597
Comment by: genius at airmail dot net
Reported By: grugli at mmedia dot is
Status: Bogus
Bug Type: MySQL related
Operating System: Windows XP
PHP Version: 4.3.1
New Comment:
I made the previous comment too quickly, it appears to me that this
indeed is a php (for win32 .. cause it tested on linux w/o problems)
problem.
when running mysql command line this command 'select * from pictures
order by rand()' produces random results, however when calling that
same command from php it always returns the same result.
in my previous post i was running 'select * from pictures order by
rand(now())' from the command line which returns the same result every
time, which lead me to believe the bug was in mysql.
someone please reopen this bug report
Previous Comments:
------------------------------------------------------------------------
[2003-03-12 20:45:54] genius at airmail dot net
The bug is in mysql as I can reproduce it from the command-line. It
also may be windows-specific ... this bug is often mistaken for not
providing a random seed i.e. rand(now()) but the problem persists even
with the seed.
------------------------------------------------------------------------
[2003-03-08 05:27:47] georg@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
PHP uses the same api call (mysql_query/mysql_real_query) as in mysql
command line client and it doesn't change the query string.
------------------------------------------------------------------------
[2003-03-07 18:42:13] grugli at mmedia dot is
This MySql-query doesn't seem to work.
$Query = "select * from $TableName ORDER BY RAND() LIMIT 1";
The only thing that the query returns is the first row and nothing
else.
ORDER BY RAND() works very well from the mysql command line but does
not work right through PHP.
The same bug was reported in september 2001 (Bug #13287) and was closed
by derick@php.net becuse he thought it was a mysql-bug
I know this is not a MySql-bug. It must be a bug in PHP becuse the
mysql-command line works fine.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22597&edit=1