-5
當使用本地主機(使用PHP內置服務器)我的PHP文件加載正確,一切都顯示,但是當我上傳到一個實際的服務器,並嘗試訪問它,我收到以下錯誤:PHP:無法加載資源
GET http://shunterweb/ 500 (Internal Server Error)
這裏是PHP代碼
<?php
require_once(__DIR__.'/../config.php');
// Get the DB connection settings
$dbHost = $config["db"]["server"]["host"];
$dbUser = $config["db"]["server"]["username"];
$dbPass = $config["db"]["server"]["password"];
$dbName = $config["db"]["server"]["dbname"];
$connectionInfo = array("Database"=>$dbName, "UID"=>$dbUser, "PWD"=>$dbPass);
$conn = sqlsrv_connect($dbHost, $connectionInfo);
if($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
//declare the SQL statement that will query the database
$query = "SELECT YardId,Yard FROM YWBYard";
$params = array();
$options = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
//execute the SQL query and return records
$result = sqlsrv_query($conn, $query);
if($result === false){
if(($errors = sqlsrv_errors()) != null) {
foreach($errors as $error) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
else {
$numRows = sqlsrv_num_rows($result);
//echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = sqlsrv_fetch_array($result))
{
if($row['YardId']===1){
echo "<li>"."<a href="."http://localhost:8080/".">".$row['Yard'],"</a></li>";
}
elseif($row['YardId']===2){
echo "<li>"."<a href="."http://localhost:8080/bicker.php".">".$row['Yard'],"</a></li>";
}
else{
echo "<li>"."<a href="."http://localhost:8080/crick.php".">".$row['Yard'],"</a></li>";
}
}
}
//close the connection
sqlsrv_close($conn);
?>
有什麼事情在我的代碼或將本是服務器端?
無論是或兩者。檢查服務器盒上的錯誤日誌。 –
檢查錯誤日誌。 Apache和PHP錯誤日誌。 –
可能有些東西與您測試時不在同一個地方 – RiggsFolly