Jump to content

damn you /r/n. damn you!


zerGinfested

Recommended Posts

Grabbing the Body row from my table is giving me a MAJOR headache here. it is littered with forward slashes infront of quotes ( /" where it should just be " ) as well as r/n/ where <br>'s should be. I've tried str_replacing them both but to no avail. It simply returns them all the same. Is there a simple error in my code that I'm missing? Let's hope so  :shrug:

 

if(isset($id)){

$query = "SELECT * FROM news where id='$id'";

$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result) or die(mysql_error());

$body = $row[body];

str_replace('\r\n', '<br>', $body);

print

"<div class='articletitle'>$row[title]</div><br />

        <div class='maintext'><em>Released $row[date]</em><br><br>$body</div>";

                  }

 

 

Link to comment
https://forums.phpfreaks.com/topic/193508-damn-you-rn-damn-you/
Share on other sites

check the data in the db. if it has too many slashes to escape quotes etc then there is a problem when you are entering the data into the db.

 

I'm using a wysiwyg so clients can copy and paste from their word processors (which I know is headache enough) but yes, it is creating the /r/n right from the get go. Should i be doing the str_replace before it is entered in the db, rather than when it is pulling it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.