我已经编写了这段代码来连接到 MySQL 服务器。但是,它似乎不起作用。有人可以告诉我为什么会这样吗?
<?php
$username = "user";
$password = "password";
$hostname = "hostname";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$selected = mysql_select_db("asantec",$dbhandle)
or die("Could not select asantec");
$result = mysql_query("SELECT * FROM books");
//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
echo "tile:".$row{'title'}." author:".$row{'author'}."price: ". //display the results
$row{'price'}."<br>";
}
//close the connection
mysql_close($dbhandle);
?>