-3

我正在尝试创建一个脚本来显示我的 MYSQL 数据库信息,但我不断收到这些错误:

注意:第 103 行的 /home/head1sta/public_html/index.php 中不存在表“head1sta_news.news”

和:

警告:mysql_fetch_row():提供的参数不是第 104 行 /home/head1sta/public_html/index.php 中的有效 MySQL 结果资源

当我在这里和那里调整代码试图弄清楚我在搞砸什么时,它已经发生了变化。这是脚本:

<?
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]");
}
?>
4

1 回答 1

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.

于 2013-06-24T20:23:40.110 回答