试图访问我机器上的 MySQL 数据库。它位于端口 1338 上。
这是 PHP 文件:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
<?php
$connection = mysql_connect("localhost:1338","root","password"); //connects to db
$selected = mysql_select_db("site_updatelog"); //selects the db to be used
//Check whether connection was successful
if(!$connection){
die('Could not connect to database: ' . mysql_error()); //Stop further execution of php script and show the error that occured
}
$sql = "SELECT comments, version, datetime FROM changeLog ORDER BY id DESC"; //form the query to be executed on the db
$result = mysql_query($sql, $connections) or die (mysql_error()); //execute the query, or die if there was an error
while($row = mysql_fetch_array($result)){
//Display the table of results
echo "<tr><td>". $row['version'] ."</td><td>". $row['comments'] ."</td><td>". $row['datetime'] ."</td></tr>";
}
mysql_close($connection);
?>
</table>
</body>
</html>
这是输出:
"; } mysql_close($connection); ?>
". $row['version'] ." ". $row['comments'] ." ". $row['datetime'] ."
折腾了好久还是不行。有任何想法吗?