I have a bizarre problem and would greatly appreciate any help.
I am administering several web sites. On each I have installed the same mySQL databases and PHP code, on servers which are similarly configured. However the code is behaving differently on each domain.
I\'m trying to use \"ORDER BY RAND() limit 1\" to retrieve a random record. On \"Domain A\" this is working flawlessly. On \"Domain B\" it appears to work once and a (very great) while -- but almost never. And, on \"Domain C\" this rarely works at all.
Each domain has the following set up:
domainA.com
PHP version = 4.2.1
mySQL version = 3.23.54
table = 110 records
Apache Version = 1.3.24 (Unix)
domainB.com
PHP version = 4.2.1
mySQL version = 3.23.54
table = 78 records
Apache Version = 1.3.24 (Unix)
domainC.com
PHP version = 4.2.1
mySQL version = 3.23.54
table = 45 record
Apache Version = 1.3.26 (Unix)
And each domain has the following table definition:
CREATE TABLE Quote_Board (
Quote_ID int(11) NOT NULL auto_increment,
Quote text NOT NULL,
Person text NOT NULL,
URL text,
Type set(\'Spoken\',\'IM\',\'Email\',\'Other\') default \'Spoken\',
Submitted_by text,
Quote_Date date default NULL,
Submission_Date date default NULL,
approved enum(\'Y\',\'N\') NOT NULL default \'N\',
PRIMARY KEY (Quote_ID)
) TYPE=MyISAM;
And each domain is using the following PHP code:
$query = "SELECT * FROM `Quote_Board` WHERE approved = \'Y\' ORDER BY RAND() limit 1";
$result = mysql_query($query) or die("Query failed");
while ($quote = mysql_fetch_array($result, MYSQL_BOTH)) {
// print resutls in HTML
}
mysql_free_result($result);
I just can\'t figure out why it is working so well on one domain and so poorly on the other.
Thanks in advance for any help,
Dave