Trying to access array offset on value of type bool in

Résolu/Fermé
franksh Messages postés 40 Date d'inscription dimanche 8 juillet 2018 Statut Membre Dernière intervention 1 novembre 2023 - 11 déc. 2020 à 19:56
franksh Messages postés 40 Date d'inscription dimanche 8 juillet 2018 Statut Membre Dernière intervention 1 novembre 2023 - 11 déc. 2020 à 22:14
Bonjour,

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
A voir également:

3 réponses

yg_be Messages postés 22774 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 10 mai 2024 1 481
11 déc. 2020 à 20:08
bonjour,
pourrais-tu partager le message d'erreur complet, inclus la ligne où l'erreur se produit?
1
franksh Messages postés 40 Date d'inscription dimanche 8 juillet 2018 Statut Membre Dernière intervention 1 novembre 2023
11 déc. 2020 à 20:11
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
0