- Impact
- 1
I'm trying to pull a random quote from my database but keep getting the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/t/w/i/twiztedfake/html/index.php on line 27
Line 27 is:
$row = mysql_fetch_array($result);
Whats wrong?
**Update
While looking around some resource sites I found a code snipplet that seems to work for it. Here it is:
If you think there is a better way to do this please let me know.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/t/w/i/twiztedfake/html/index.php on line 27
Line 27 is:
$row = mysql_fetch_array($result);
PHP:
<?php
$sql = "SELECT * FROM ct_quotes WHERE ID > '0' ORDER by ID RAND LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo stripslashes($row['quote']);
?>
Whats wrong?
**Update
While looking around some resource sites I found a code snipplet that seems to work for it. Here it is:
PHP:
<?php
$sql = "SELECT * FROM ct_quotes ORDER BY ID";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$row_array[] = $row['quote'];
}
$random_row = $row_array[rand(0, count($row_array) - 1)];
echo stripslashes($random_row);
?>
If you think there is a better way to do this please let me know.
Last edited:





