Uncaught ErrorException: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in even though I am checkng for nulll

253 views Asked by At

I am getting following error on line 42 of my code. But strange thing is I am already checking for null and the actual error seems to be happening on line 44. How to fix this issue?

Error

Uncaught ErrorException: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/mysite/mypage.php:42

Code

while($row3 = mysqli_fetch_assoc($result3))
{
   $emailbody .= "<b>Keyword:</b> ". htmlspecialchars($row2["keyword"]) ."<br>";

   if(!is_null($row3["summary"]))     //line 42
   {
      $emailbody .= "<b>Summary:</b> ". htmlspecialchars($row3["summary"]) ."<br>";
   }
}
1

There are 1 answers

0
Mureinik On

Since you're checking for nulls on the second call, the error must be coming from the first one: htmlspecialchars($row2["keyword"]). Add a null-check on that too, and you should be OK.