我正在尝试查询SQL Server数据库并在屏幕上返回结果。我的页面按其应该加载,但是当我按下按钮来查询SQL Server时,如果我查看控制台,它会显示500错误。PHP抛出500错误
我需要更改哪些内容才能根据需要在屏幕上返回有效结果?
<select name="peopleinfo[]" multiple style="min-width: 200px;" id="peopleinfo">
<option value="red">Red</option>
<option value="blue">Blue</option>
</select>
<div><input type="submit" value="Submit" id="ajaxButton" onclick="ReturnIt()"></div>
<div id="result_data"></div>
<script>
function ReturnIt(){
var peopleinfo = $('#peopleinfo').val();
jQuery.ajax({
url: "",
type: 'POST',
dataType: "html",
data: { peopleinfo: peopleinfo },
success : function(result) {
$('#result_data').empty();
$('#result_data').append(result);
} ,
error: function(){
}
});
}
</script>
$peopleinfo = implode(',',$_REQUEST['peopleinfo']);
$option = array(); //prevent problems
$option['driver'] = 'mssql'; // Database driver name
$option['host'] = 'Lockwood'; // Database host name
$option['user'] = 'root'; // User for database authentication
$option['password'] = 'sa'; // Password for database authentication
$option['database'] = 'test'; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$db = JDatabase::getInstance($option);
$result = $db->getQuery(true);
$result->select($db->quoteName(array(".$peopleinfo.")));
$result->from($db->quoteName('[redheadstepchild]'));
$db->setQuery($result);
$row = $db->loadRowList();
print_r($row);
编辑
这就是开发者控制台中显示
在这条线jquery-1.12.4.js:10254
一个错误,这是实际的语法,当我点击
// Do send the request
// This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send((options.hasContent && options.data) || null);
该错误的原因应该在你的HTTP服务器的错误日志 – Phil
显示我没有对服务器的访问日志:0( – IcyPopTarts
是这个代码运行在Joomla环境或Joomla环境之外,如果在Joomla环境中运行,那么为什么又要提供数据库细节,为什么不使用'$ db = JFactory :: getDbo();'从哪里得到这个'[redheadstepchild ]'。 –