Search code examples
phpapostrophe

apostrophe php issue


I was making a school assignment with involves a shoutbox. A found great tutorial wich uses jquery,ajax,mysql and php. Now i run into a little problem with the following sentence:

$result .= "<li><strong>".$row['user']."</strong><img src="\" alt="\"-\""    />".$row['message']." <span class="\"date\"">".$row['date']."</span></li>";}

I was wondering if anybody could find out why it gives errors. So far I came to this conclusion $row['message'] and then it thinks the rest of the code as a string. So it probably is a apostrophe problem.


Solution

  • Just for the sake of making your life easier: use ' for the php and " for html like this:

    $result .= '<li><strong>'.$row['user'].'</strong><img src="" alt=""/>'.$row['message'].' <span class="date">'.$row['date'].'</span></li>';
    

    Pretty sure you should get the idea.