0

I search alot about this error but I didn't understand what is the problem in my setuation. I know it should be a little problem in my codes but i am learning to work on back-end codes and php.so please help me

Notice: Trying to access array offset on value of type bool on line 85 , 86

 function getProductInfo($productId){

    $sql="select * from tbl_product where id=?";
    $result=$this->doSelect($sql,[$productId], 1);

   /*85*/ $colors=$result['colors'];
    $sizes=$result['sizes'];
    $colors=explode(',',$colors);
    $sizes=explode(',',$sizes);
    $result['colorsInfo']=[];
    $result['sizesInfo']=[];
    foreach ($colors as $color){
        $sql="select * from tbl_color where id=?";
        $colorInfo=$this->doSelect($sql,[$color],1);
        array_push($result['colorsInfo'],$colorInfo);

    }

and in otherside my function don't work right. and don't send $idcategory in his right value and it send null.

  • 1
    Your query seems to have failed. What are you using for DB access? PDO? Mysqli? Something else? – El_Vanja May 20 '21 at 10:21
  • PDO.but its just in this page of my site have problem – Sarina Yousefi May 20 '21 at 10:24
  • $result is seem to be FALSE. Try to debug your `doSelect` function. – מתניה אופן May 20 '21 at 10:24
  • See [here](https://stackoverflow.com/questions/32648371/my-pdo-statement-doesnt-work/32648423#32648423) how to find out the error. – El_Vanja May 20 '21 at 10:26
  • I read it thanks with addding these lines error will be disappearing or show the error???? : `error_reporting(E_ALL); ini_set('display_errors',1); error_reporting(E_ALL); ini_set('display_errors', 0); ini_set('log_errors', 1); ` – Sarina Yousefi May 20 '21 at 10:36
  • Those don't solve the error, they just help you find it. The first option outputs the error to the screen. The other one doesn't, it logs it instead (into the error log file). – El_Vanja May 20 '21 at 10:41
  • but when i added to my Model code it disappear I think I added in wrong place – Sarina Yousefi May 20 '21 at 10:45
  • Nevermind that for now (you probably used the second option which stops displaying the message and instead logs it). Remove that and focus on PDO. The important part is `$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );`. – El_Vanja May 20 '21 at 12:59

0 Answers0