簡體   English   中英

PHP不適用於xampp / apache

[英]PHP isn't working with xampp/apache

如標題中所述,php無法與xampp / apache一起使用,而我的所有其他文件(html / css / js)都可以正常工作。
我的php調用或php代碼本身有問題嗎?
我的配置是httpd.conf和httpd_vhosts.conf中的路徑用於桌面中的文件夾。
我的html文件(使用ajax)中的php調用是:

$.ajax({
    url: './php/add_events.php',
    data: {'title': eventData.title,'start': eventData.start.format() ,'end': eventData.end.format() ,'areHere':eventData.areHere,'finalConsult':eventData.finalConsult },
    type: "POST",
    success: function(json) {
        alert("OK");
    }
});
$.ajax({
    url: './php/update_events.php',
    data: {'title': $(this).data('calEvent').title,'start': $(this).data('calEvent').start ,'end': $(this).data('calEvent').end ,'areHere':$(this).data('calEvent').areHere,'finalConsult':$(this).data('calEvent').finalConsult ,'id': $(this).data('calEvent').id },
    type: "POST",
    success: function(json) {
        alert("OK");
    }
});
$.ajax({
    url: './php/remove_events.php',
    data: {'id':$(this).data('id')} ,
    type: "POST",
    success: function(json) {
        alert("OK");
    }
});
events: './php/events.php'

請注意,我使用的是fullcalendar(基於jquery),並且“ remove_events.php”調用是唯一使我返回“ OK”作為警報的調用。
如果我必須發布php代碼,請通知我,我將對其進行編輯。
預先謝謝你!

編輯:我想精確地說,這些ajax調用中的每一個都是代碼片段,而不是完整的代碼

編輯2:瀏覽器的控制台和“網絡”標簽中沒有錯誤消息,並且它們現在都返回“ OK”作為警報

編輯3:這是add_events.php的php代碼,我希望它將從js接收的數據發送到我的數據庫:

$title=$_POST['title'];
$start=$_POST['start'];
$end=$_POST['end'];
$areHere=$_POST['areHere'];
$finalConsult=$_POST['finalConsult'];
$typeConsult=$_POST['typeConsult'];
try {
 $bdd = new PDO('mysql:host=localhost;dbname=agenda', 'root', '');
} catch(Exception $e) {
 exit('Connexion failed');
}

$sql = "INSERT INTO evenement (ID_evenement,Nom_patient,Nom_groupe,Type_consultation,Heure_debut,Heure_fin,Consulte_finale,Presence,ID_client,ID_groupe,ID_observe) VALUES ('',:title, '', :typeConsult, :start, :end, :finalConsult, :areHere, '', '','')";

$q = $bdd->prepare($sql);

$q->execute(array(':title'=>$title, ':typeConsult'=>$typeConsult ':start'=>$start, ':end'=>$end, ':finalConsult'=>$finalConsult, ':areHere'=>$areHere));

?>

編輯4:當我嘗試在瀏覽器中打開php文件或從php回顯一些信息時,它會發送類似404的錯誤

解決這些問題,這些不是URL。 它看起來更像是一個相對文件路徑

 url: './php/add_events.php',

您可以輸入完整的URL,包括域:

url: 'http://whatever.com/path/to/add_events.php',

有無:

url: '/path/to/add_events.php',

我終於找到了問題的根源,這個問題終於變得簡單了(很奇怪,這里沒有人指出)。 問題出在我的路徑上,其中包含空格和特殊字符,這對於我的環境配置是不可接受的。 因此,感謝所有人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM