I got a strange behavior that cannot allows me to delete a single line on my table, In fact, as soon as it enters the mysqli->query line that ask to delete, it stops and does nothing (the echo post after it isn't displayed at all), here is the code, and I'd like to know what's wrong :
I've posted in the deleteLine function the thing that outpouts correctly with echo, and the things that don't :
<?php
//here are the db connexion
include 'connDB.php';
//array that'll stock my values to delete
$myarray = array();
//lists all elements of the Table animals
if ($result = $mysqli->query("SELECT * FROM animals")) {
while($row = $result->fetch_array(MYSQL_ASSOC)) {
//searching for some specific lines
$delay= timePassed($row["time"]);
if($delay >= 60){
//save the id of the line in an array
$myArray[] = $row["id"];
}
}
}
$result->close();
//Once all my lines to delete are saved in my array, let's delete it
for($i=0;$i<count($myArray);$i++){
//will call and delete one line by one
deleteLine($myArray[$i]);
}
$mysqli->close();
////////////////////////////////////////////////////////////////////////////////////////////////TIMEPASSED
//just to compare 2 timestamps between them
function timePassed($dateToCompare){
$dateNow = time();
$res =round(($dateNow-$dateToCompare)/(60*60));
return $res;
}
////////////////////////////////////////////////////////////////////////////////////////////////DELETELINE
function deleteLine($id){
echo $id; //OUTPUTS CORRECTLY THE ID OF THE LINE TARGETED (in my case : 83)
$mysqli->query("DELETE FROM animals WHERE id=".$id);
echo"line deleted"; //THIS NEVER OUTPUTS
}
?>