Hello all,
I'm trying to create a shoutbox, to learn about more about using SQL, but I'm running into a problem.
//The problematic code:
<?php
mysql_connect(localhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die("Unable to select database!");
$read_query = "SELECT * FROM message";
$read_result = mysql_query($read_query);
$read_rows = mysql_num_rows($read_result);
// Read from DB.
while ($i < $read_rows);
{
$read_id = mysql_result($read_result,$i,"id");
$read_name = mysql_result($read_result,$i,"name");
$read_url = mysql_result($read_result,$i,"url");
$read_message = mysql_result($read_result,$i,"message");
$i++;
}
mysql_close();
?>
That part of the code is giving me the error:
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /var/www/php/shoutbox.php on line 44
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /var/www/php/shoutbox.php on line 45
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /var/www/php/shoutbox.php on line 46
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /var/www/php/shoutbox.php on line 47
I got the same error earlier today, when I was practicing, but gave up after not being able to fix it,
I'm sure there's a simple solution to this. Anyone care to give me an explaination as to what's going wrong? 🙂
Thanks.
TrickyPhillips