Y.Bernard Y.Bernard - 1 month ago 11
Ajax Question

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.

Is there a problem with my php calls, or in php code itself ?

My configuration is that the path in httpd.conf and httpd_vhosts.conf are for a folder in desktop;

My php calls in my html file (with ajax) are that :

$.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.

Notify me if i have to post the php codes and i'll edit that post.

Thanks you in advance !

EDIT : I want to precise that each one of those ajax calls are snippets and aren't the full code

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

EDIT 3 : Here's the php code for add_events.php, i want it to send the data received from js to my db :


$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

Answer Source

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.