-3

I am trying to create a script to display my MYSQL db info and I keep getting these errors:

Notice: Table 'head1sta_news.news' doesn't exist in /home/head1sta/public_html/index.php on line 103

And:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/head1sta/public_html/index.php on line 104

It has varied as I have tweaked the code here and there trying to figure out what I am messing up on. This is the script:

<?
mysql_connect("localhost", "****_news", "****");
mysql_select_db("****_news");
$query = "SELECT * FROM news ORDER BY id DESC";
$result = mysql_query($query) or trigger_error(mysql_error());
while($data = mysql_fetch_row($result)){
  echo("$data[1] , $data[0] , $data[3]");
}
?>
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102

1 Answers1

1

You havent set up for database correctly it doesnt have the table / the user doesnt have permission to see the table

head1sta_news.news

By the table name above i assume your reading from a head first book ? If so PLEASE get a more recent version, If its suggesting mysql_connect its at least a few years out of date.

The second error is actually a result of the first not being handled correctly also.

exussum
  • 18,275
  • 8
  • 32
  • 65