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 = "";
CodePudding user response:
Wrong if format
$result = condition ? valueTrue : valueFalse;
Your if should be like this:
$you = ($outgoing_id == $row2['outgoing_msg_id']) ? "You: " : "";
CodePudding user response:
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: " : "";