I have a PHP file create_json.php that creates a json file from a table in my database i want my app to load that file in order to recreate the json file every time i start it
here is what i tried to do
<script language="javascript" type="text/javascript">
window.onload = function(){
$.ajax({
type: "GET",
url: "create_json.php" ,
success : function() {
alert("created");
}
}).error(function(){
alert('error... ohh no!');
});
}
</script>
I have no error i get the "created alert but the file is not created and i'm sure that my create_json.php file works it works perfectly when i execute it on a browser it just dont work on my app help please here is the php file content
$conn= mysqli_connect("localhost","root","") or die ("could not connect to mysql");
mysqli_select_db($conn,"bd") or die ("no database");
$sql=mysqli_query($conn,"select * from user");
$response = array();
$user = array();
$result=$sql;
while($row=mysqli_fetch_array($result))
{
$email=$row['email'];
$mdp=$row['mdp'];
$user[] = array('email'=> $email, 'mdp'=> $mdp);
}
$response['user'] = $user;
$fp = fopen('C:\Users\Oussemat\Documents\PFE11\wwwesults.json', 'w');
fwrite($fp, json_encode($response));
fclose($fp);
?>