<html> 
<head><title>Web Database Sample Index</title> 
</head> 
<body bgcolor=#ffffff> 
<h2>Data from tbl</h2> <? 
mysql_connect(Mysql, root, root) or die ("Problem connecting to DataBase"); 
$query = "select * from stemp"; 
$result = mysql_db_query("stemp", $query); if ($result) { 
echo "Found these entries in the database:<br><p></p>"; 
echo "<table width=90% align=center border=1><tr> 
<td align=center bgcolor=#00FFFF>User Name</td> 
<td align=center bgcolor=#00FFFF>Last Name</td> 
<td align=center bgcolor=#00FFFF>Domain Name</td> 
<td align=center bgcolor=#00FFFF>Request Date</td> 
</tr>"; while ($r = mysql_fetch_array($result)) 

$id1 = $r["id1"]; 
$id2 = $r["id2"]; 
$id3 = $r["id3"]; 
echo "<tr> 
<td>$id1</td> 
<td>$id2</td> 
<td>$id3</td> 
<td></td> 
</tr>"; 

echo "</table>"; 

else 

echo "No data."; 
} mysql_free_result($result); 
include ('links.x'); 
?> </body> 
</html>

解决方案 »

  1.   

    mysql_connect(Mysql, root, root)这里有问题,如果在本机上,就写:mysql_connect("localhost", root, root)
      

  2.   

    现在有出现其另外一个错误,帮忙看看。谢谢!
    Warning: mysql_connect(): Access denied for user: 'root'@'localhost' (Using password: YES) in D:\my work\stempsite\test.php on line 8
    Problem connecting to DataBase
      

  3.   

    进入mysql
    mysql>grant all on *.* to root@localhost identified by 'root';
    再试程序
      

  4.   

    有错误
    mysql> grant all on *.* to root@localhost identified by 'root';
    ERROR 1045 (28000): Access denied for user: ''@'localhost' (Using password: NO)
      

  5.   

    前面是这样进入的
    c:\mysql\bin> mysql [回车]
    mysql> grant all on *.* to root@localhost identified by 'root'; [回车]
    ERROR 1045 (28000): Access denied for user: ''@'localhost' (Using password: NO)
    后来这样进入的
    c:\mysql\bin> mysql -uroot -root [回车]
    mysql> grant all on *.* to root@localhost identified by 'root'; [回车]
    Ignoring query to other database
      

  6.   

    C:\mysql\bin> mysql -uroot -p
    ******** (输入root密码)mysql> GRANT ALL ON *.* TO scc@'%' IDENTIFIED BY 'scc';然后用
    mysql_connect("localhost", "scc", "scc")
    连接试试结果。