Alright I am trying to get this highlight_string function to work without any luck at all. Here is my code without the highlight_string in there. { $output .= " <hr> <div class='grey_top'></div> <div class='grey'> <a href='$row->website'>$row->name</a> says:<br><br> $row->comment </div> "; } echo $output; PHP: This is the page I am trying to get work. http://www.phpelf.com/echo.php Basically you can post a comment and I would expect php code to be in that comment. Now when I return it I would like just the comment portion to be highlighted. Any ideas?
Here is some code, perhaps you need to make sure you input a <?php ?> where you want php code to be highlighted. <?php $comment="Here is a comment about stuff ha ha ha. Oh some php code sounds like fun. <?php echo 'some stuff about something in php'; ?> "; highlight_string ($comment); ?> PHP: the code above takes the comment and just highlights the part contained in the <?php ?> tags.
Well it displays properly when I have it out of the while. But when I put it in it dont work for some reason. Works like this.. while ( $row = mysql_fetch_object($result) ) { $string_comment = $row->comment; echo " <br><div class='grey_top'></div> <div class='grey'> <a href='$row->website'>$row->name</a> says:<hr><br> </div>"; } highlight_string($string_comment); PHP: But dont work when I put that line inside the While.
I got it. Just had to break the echo and then do the highlight then start the echo back up. while ( $row = mysql_fetch_object($result) ) { $string_comment = $row->comment; echo " <br><div class='grey_top'></div> <div class='grey'> <a href='$row->website'>$row->name</a> says:<hr><br>"; highlight_string($string_comment); echo "</div>"; } PHP: That only killed an hour.
I know what you mean, seems like the smallest problems take up a lot of time. I tend to just take a break from coding for an hour or so when i cant seem to wrap my head around a problem i cant find. Works wonders i usually fix it in 10 seconds when i come back.