简体   繁体   English

PHP不适用于xampp / apache

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

As said in the title, php isn't working with xampp/apache where all my other files (html/css/js) works well. 如标题中所述,php无法与xampp / apache一起使用,而我的所有其他文件(html / css / js)都可以正常工作。
Is there a problem with my php calls, or in php code itself ? 我的php调用或php代码本身有问题吗?
My configuration is that the path in httpd.conf and httpd_vhosts.conf are for a folder in desktop; 我的配置是httpd.conf和httpd_vhosts.conf中的路径用于桌面中的文件夹。
My php calls in my html file (with ajax) are that : 我的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'

Note that i'm using fullcalendar (based on jquery) and that the "remove_events.php" call is the only one that returns me a "OK" as alert. 请注意,我使用的是fullcalendar(基于jquery),并且“ remove_events.php”调用是唯一使我返回“ OK”作为警报的调用。
Notify me if i have to post the php codes and i'll edit that post. 如果我必须发布php代码,请通知我,我将对其进行编辑。
Thanks you in advance ! 预先谢谢你!

EDIT : I want to precise that each one of those ajax calls are snippets and aren't the full code 编辑:我想精确地说,这些ajax调用中的每一个都是代码片段,而不是完整的代码

EDIT 2 : There's no error message in the browser's console and network tab and they're now all returning an "OK" as alert 编辑2:浏览器的控制台和“网络”标签中没有错误消息,并且它们现在都返回“ OK”作为警报

EDIT 3 : Here's the php code for add_events.php, i want it to send the data received from js to my db : 编辑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));

?>

EDIT 4 : When i try to open the php file in browser or to echo some infomations from php, it sends a 404-like error 编辑4:当我尝试在浏览器中打开php文件或从php回显一些信息时,它会发送类似404的错误

Fix these, those aren't URLs. 解决这些问题,这些不是URL。 It looks more like a relative file path 它看起来更像是一个相对文件路径

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

You can either put the full URL including the domain: 您可以输入完整的URL,包括域:

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

Or without: 有无:

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

I finally found the source of the problem that was finally simple (that's strange that no one here pointed it). 我终于找到了问题的根源,这个问题终于变得简单了(很奇怪,这里没有人指出)。 The problem came from my path, which contained spaces and special characters, that was not accepted for the configuration of my environment. 问题出在我的路径上,其中包含空格和特殊字符,这对于我的环境配置是不可接受的。 So thanks to all however. 因此,感谢所有人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM