<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>
<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>
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
mysql>grant all on *.* to root@localhost identified by 'root';
再试程序
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 [回车]
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
******** (输入root密码)mysql> GRANT ALL ON *.* TO scc@'%' IDENTIFIED BY 'scc';然后用
mysql_connect("localhost", "scc", "scc")
连接试试结果。