未能加载资源:加载php脚本时,服务器响应状态为500(内部服务器错误)
我现在已经删除了我的凭据,所以这又是我的问题,每当我尝试在我的网站上运行php脚本时,我都会收到500个内部服务器错误,权限设置为644,所以这不是问题所在 以下是我正在运行的html代码:未能加载资源:加载php脚本时,服务器响应状态为500(内部服务器错误),php,mysql,xampp,internal-server-error,Php,Mysql,Xampp,Internal Server Error,我现在已经删除了我的凭据,所以这又是我的问题,每当我尝试在我的网站上运行php脚本时,我都会收到500个内部服务器错误,权限设置为644,所以这不是问题所在 以下是我正在运行的html代码: <html> <head> <title></title> </head> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jque
<html>
<head>
<title></title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div class = "container">
<nav class = "navbar navbar-inverse">
<div class = "container-fluid">
<div class = "navbar-header">
<a class = "navbar-brand" href = "index.html">YardSaleMapper.com</a>
</div>
<ul class = "nav navbar-nav">
<li><a href = "index.html">Go Home</a></li>
<li class = "active"><a href = "viewSales.php">View Sales</a></li>
<li><a href = "addSale.html">Publish your Sale</a></li>
</ul>
</div>
</nav>
<h3>Enter Starting Point</h3>
<hr/>
<form method = "post" id = "myForm">
<div class = "col-md-2">
<div class = "form-group">
Street:
<input class = "form-control" type = "text" name = "start_street" ng-model = "ss" required/>
</div>
</div>
<div class = "col-md-2">
<div class = "form-group">
City:
<input class = "form-control" type = "text" name = "start_city" ng-model = "ss" required/>
</div>
</div>
<div class = "col-md-2">
<div class = "form-group">
State (EX: PA):
<input class = "form-control" type = "text" name = "start_state" ng-model = "ss" maxlength="2" required/>
</div>
</div>
<div class = "col-md-2">
<div class = "form-group">
ZIP
<input class = "form-control" type = "text" name = "start_zip" ng-model = "ss" maxlength="5" required/>
</div>
</div>
<div class = "col-md-2">
<div class = "form-group">
Within <select type = "text" name = "distance" required class = "form-control">
<option value = 5>5</option>
<option value = 10>10</option>
<option value = 15>15</option>
<option value = 20>20</option>
<option value = 25>25</option>
</select>
Miles
</div>
</div>
<div class = "col-md-2">
<div class = "form-group">
 
<a class ="btn btn-primary btn-block" id = "submit" name = "submit">Submit</a>
</div>
</div>
</form>
</div>
<script id = "source" language = "javascript" type = "text/javascript">
$(function() {
$('#submit').on('click', function() {
$.ajax({
url: 'getSales.php',
method: 'post',
data: $("#myForm").serialize(),
dataType: 'json',
success: function(data) {
console.log(data);
}
})
})
});
</script>
</body>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</html>
输入起点
街道:
城市:
州(前:PA):
拉链
在内部
5.
10
15
20
25
英里
 
你可以看到那里没有源代码,但是我已经提供了我上面写的源代码,所以我认为这可能是主要问题 页面似乎没有回显数据,您确定您的$data不是空的吗
您可以通过使用var_dump($data)看到这一点
文件
我建议您尝试直接从浏览器运行php文件,使用$street、$city、$state、$zip、$dist的硬编码值,查看浏览器是否可以以json格式显示回显数据。500表示服务器端错误(php或其他)。首先查看服务器日志以查看错误。您刚刚发布了数据库登录。。另外,别忘了逃避查询!我强烈建议您从帖子中删除数据库凭据和信息,并更改凭据。您可以在帖子历史记录中看到数据库信息。最好改变它@AleksG错误日志显示我的所有变量都未定义:yardsalessepa-com.stackstaging.com[Thu Apr 20 16:05:54 2017][error][client 108.16.165.106:60742]PHP注意:未定义索引:start_street in/home/sites/1b/5/5bd76b5e0c/public_html/getSales.PHP,第17行,但我不明白这是怎么回事,因为如果你看代码,你可以清楚地看到它们是以正确的方式访问的,这没有任何作用。我在PHP文件的第1行发现一个错误,当我在源代码中查看它时,它是完全空白的。您可以尝试将.ajax({…})更改为.post({…}),这仍然没有做任何事情。
<?php
$servername = "....";
$username = "....";
$password = "....";
$dbname = "....";
$data = array();
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$street = $_POST["start_street"];
$city = $_POST["start_city"];
$state = $_POST["start_state"];
$zip = $_POST["start_zip"];
$dist = $_POST["distance"];
$address = $street . ", " . $city . ", " . $state . ", " . $zip;
$geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false');
// Convert the JSON to an array
$geo = json_decode($geo, true);
if ($geo['status'] == 'OK') {
// Get Lat & Long
$lat = $geo['results'][0]['geometry']['location']['lat'];
$long = $geo['results'][0]['geometry']['location']['lng'];
}
$sql = "SELECT street, city, state, zip, county, sdate, edate,
stime, etime, description, 69 * vincenty($lat, $long, lat, long) AS distance from
sjodsijfoisjdf237423947 where 69 * vincenty($lat, $long, lat, long) < $dist";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$data[] = $row;
echo($row);
}
echo json_encode($data);
?>