我有一個PHP腳本,將信息放入數據庫。 當我在服務器上手動運行該腳本所有按預期工作。 但是當我運行通過使用Ajax的PHP腳本的JavaScript非常腳本在下面的行失敗:mysqli當直接運行,但不是通過js-ajax時,作品
$connection=new mysqli($servername,$username,$password,$dbname);
,我得到的錯誤是 PHP致命錯誤:類「庫MySQLi」在/ var找不到/ WWW/html/..
這對我沒有任何意義,因爲我只是直接在服務器上運行該腳本而沒有任何問題。
我在/var/log/apache2/error.log中發現此錯誤。
這裏是我的ajax調用的樣子:
$.ajax({
url:'db/insert.php',
complete: function(response){
//$('#output').html(response.responseText);
alert('complete: '+response.responseText);
},
error: function(){
//$('#output').html('Bummer: there was an error!');
alert('error');
},
async:"false",
type:"POST",
data:{visit_report:'1'}
});
爲什麼腳本以這種方式失敗?
這個問題是繼續在這裏: Enable mysqli in my in-webserver copy of php
你檢查是否mysqli的是PHP的你在,Web服務器副本啓用?命令行和SAPI具有不同的.ini文件,這些文件不一定啓用了相同的模塊。 –
我該怎麼做? –
發佈您使用ajax調用的頁面。 –