Hiya folks.
I am trying to create a table containing a list of fixtures and results for the new Premiership season using a MySQL database. I am trying to output everything into a nice table but am getting the following error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/.sites/146/site439/web/united/displayfixtures2.php on line 30
Here is the code I am using:
<?php
$dbhost = "***";
$dbusername = "***";
$dbpassword = "***";
$database = "***";
mysql_connect($dbhost, $dbusername, $dbpassword);
mysql_select_db($database);
echo '<table width="100%" border="1" cellpadding="0">';
echo '<tr>';
echo '<td width="20%" align="center" bgcolor="FFFFFF">';
echo 'Date';
echo '</td>';
echo '<td width="40%" align="center" bgcolor="FFFFFF">';
echo 'Opposition';
echo '</td>';
echo '<td width="20%" align="center" bgcolor="FFFFFF">';
echo 'Home/away';
echo '</td>';
echo '<td width="20%" align="center" bgcolor="FFFFFF">';
echo 'Score';
echo '</td>';
echo '</tr>';
$query = "SELECT id, date, opposition, venue, result FROM fixtures";
$result = mysql_query($query);
while ($query_data = mysql_fetch_row($result))
{
$id = $query_data[0];
$date = $query_data[1];
$opposition = $query_data[2];
$venue = $query_data[3];
$result = $query_data[4];
echo '<tr>';
echo '<td width="25%" bgcolor="FFFFFF">';
echo $date;
echo '</td>';
echo '<td width="25%" bgcolor="FFFFFF">';
echo $opposition;
echo '</td>';
echo '<td width="25%" bgcolor="FFFFFF">';
echo $venue;
echo '</td>';
echo '<td width="25%" bgcolor="FFFFFF">';
echo $result;
echo '</td>';
echo '</tr>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
?>
As far as I can see, that should be working fine but it aint 🙁
If it helps at all, you can see the actual page here: http://www.2312.co.uk/united/displayfixtures2.php
I am willing to bet it is a stupid typo on my part but I can't see where 🙁
Edit: It may also help to note that the database does actually contain information 🙂
Ta for any help 🙂
Stu