Ok, I'm trying to access some simple table cells from a mySql database. Whenever the page loads I get this error:
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/xxxxxxx.com/httpdocs/dbase_test.php on line 10
I don't understand because this is basically a straight copy of some textbook functions. Any help would be greatly appreciated. Here's the code:
<?php
include ("dbvars.inc");
$global_dbh = mysql_connect($hostname, $username, $password);
mysql_select_db($db, $global_dbh);
function display_db_table($tablename, $connection)
{
$query_string = "select * from $tablename";
$result_id = mysql_query($query_string, $connection);
$column_count = mysql_num_fields($result_id);
print("<table border = 1>\n");
while($row = mysql_fetch_row($result_id));
{
print("<tr align=left valign=top>");
for($column_num=0; $column_num<$column_count; $column_num++)
print("<td>$row[$column_num]</td>\n");
print("</tr>\n");
}
print("</table>\n");
}
?>
Then the function is called within the html:
<?php display_db_table("country", $global_dbh); ?>
Thanks in advance.