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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.