我試圖運行這個簡單的PHP代碼(在一個名爲「database.php中」)php只是停止工作/故障。顯示源代碼
<html>
<head>
</head>
<body>
<?php
$servername = 'localhost';
$username = 'admin';
$password = 'admin1';
//Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die('Connection failed: ' . $conn->connect_error);
}
else {
echo 'Connected Successfully.' ;
}
$conn->close();
?>
</body>
</html>
,這裏是在瀏覽器中輸出
connect_error)
{ die('Connection failed: ' . $conn->connect_error); }
else { echo 'Connected Successfully.' ; }
$conn->close();
?>
(第一PHP代碼的一部分得到處理,但後來它只顯示源代碼)
請幫助。
使用PHP安裝Web服務器。 – 2014-10-26 16:17:48
您能否指定 – 2014-10-26 16:17:53
您還需要傳遞第四個參數'$ conn = new mysqli($ servername,$ username,$ password,$ db_name);' – 2014-10-26 16:20:38