我正在嘗試查詢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 ]'。 –