Trying to access array offset on value of type bool in
Résolu
Bonjour,
Je suis en galère depuis quelques heures avec une fonction qui marché jusqu'à maintenant,
Merci d'avance
le code en question :
le message d'erreur :
Merci d'avance
Je suis en galère depuis quelques heures avec une fonction qui marché jusqu'à maintenant,
Merci d'avance
le code en question :
if(!function_exists('relation_link_to_display')){
function relation_link_to_display($id){
global $db;
$q = $db->prepare('SELECT user_id1, user_id2, status FROM friends_relationships
WHERE (user_id1 = :user_id1 AND user_id2 = :user_id2)
OR (user_id1 = :user_id2 AND user_id2 = :user_id1)');
$q->execute([
'user_id1' => get_session('user_id'),
'user_id2' => $id
]);
$data = $q->fetch();
// var_dump($data);
if($data['user_id1'] == $id && $data['status'] == '0'){ // même erreur ici
return "accept_reject_relation_link";
}elseif($data['user_id1'] == get_session('user_id') && $data['status'] == '0'){ // même erreur ici
return "cancel_reject_relation_link";
}elseif(($data['user_id1'] == get_session('user_id') or $data['user_id1'] == $id)
AND $data['status'] == '1'){ // même erreur ici
return "delet_relation_link";
}else{
return "add_relation_link";
}
$q->closeCursor();
}
}
le message d'erreur :
//Notice: Trying to access array offset on value of type bool in
Merci d'avance
3 réponses
-
Contributeurbonjour,
pourrais-tu partager le message d'erreur complet, inclus la ligne où l'erreur se produit?-
Lignes 19 , 22, 26 (voir code poster) qui correspond lignes 897 , 901 .... Sur mon editeur
// Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 897 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 901 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // bool(false) // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 897 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 901 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // bool(false) // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 897 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 901 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // bool(false) // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 897 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 901 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905 // // Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\date\inc\functions.php on line 905
-