Skip to content
Advertisement

Get Error “Warning: Trying to access array offset on value of type null in”

Here’s the error

I wan’t to add text “You” Before msg but it getting error. my php code :

($outgoing_id == $row2[‘outgoing_msg_id’]) ? $you = “You: ” : $you = “”;

Advertisement

Answer

i think this error returned due to the nullable of the $row2 this besides the wrong format of the condition as @DamianCabelloJiménez mentioned we can add a little edit to @DamianCabelloJiménez answer to handle the nullable case

$you = (isset($row2['outgoing_msg_id']) && $outgoing_id == $row2['outgoing_msg_id']) ?  "You: " : "";
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement