V phpMyAdmin som si vytvoril používateľa "user" s heslom "heslo". Vytvoril sa mi úspešne a pridelil som mu práva SELECT, INSERT, UPDATE, DELETE.
Mám takýto kód:
Kód:
<?php
// Connect and select a database
mysql_connect("localhost", "user", "heslo");
mysql_select_db("addressBook");
// Run a query
$result = mysql_query("SELECT * FROM colleague");
?>
<!DOCTYPE html PUBLIC "—//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Address Book</title>
<meta http-equiy="content—type" content="text/html;charset=utf—8" />
</head>
<body>
<h1>Address Book</h1>
<table border="1" cellpaddinq="2" cellspacing="3"
summary="Table holds colleague contact information">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Telephone</th>
<th>Email Address</th>
</tr>
<?php
// Loop through all table rows
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['firstName'] . "</td>";
echo "<td>" . $row['lastName'] . "</td>";
echo "<td>" . $row['telephone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
// Free result memory and close database connection
mysql_free_result(Sresult);
mysql_close();
?>
</table>
</body>
</html>
Keď ho spustím, napíše sa mi toto:
Citácia:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'localhost' (using password: YES) in G:\xampp\htdocs\home\test.php on line 3
Address Book
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\xampp\htdocs\home\test.php on line 28
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in G:\xampp\htdocs\home\test.php on line 38
Databázu mám urobenú a používateľ má práva. Ale keď používateľovi "user" vymažem heslo a upravím php skript napíše sa mi iba toto:
Citácia:
Address Book
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\xampp\htdocs\home\test.php on line 28
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in G:\xampp\htdocs\home\test.php on line 38
Keď idem cez roota s heslom tak sa napíše to isté, ako keby sa prihlasoval "user" bez hesla.
Ako môžem nastaviť phpMyAdmin tak, aby som mohol používať používateľa "user" s heslom?