2017-08-08 199 views
-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); 
?> 

有什么事情在我的代码或将本是服务器端?

+0

无论是或两者。检查服务器盒上的错误日志。 –

+0

检查错误日志。 Apache和PHP错误日志。 –

+0

可能有些东西与您测试时不在同一个地方 – RiggsFolly

回答

-4

您可能会收到警告或致命错误。要在服务器上显示的所有错误,

你需要写这条线在页面的页眉

error_reporting(E_ALL); 

OR

error_reporting(1); 

它会显示PHP的所有错误