Jump to content


Photo

insert into mysql database: everything is in html


  • Please log in to reply
2 replies to this topic

#1 walnoot

walnoot
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 May 2006 - 12:21 PM

Hi guys,

I have created a news system based on php and mysql.

now my problem is that when i fill in the form to insert de 'news' into my database, it inserts the text in 'html'-code.

so what I mean is this:

this is what i type in my form to insert into the database: (for example)
This is my new news post<br>
<br>
<br>
<b>Down down down</b><br>
<br>
<br>
Under :)

And this is what i get when i read it from the database news table:
"This is my new news post


Down down down


Under :)"


NOW what i want to be able to do is i want to type this in my form (you see, without the html codes like '<br>'):
This is my new news post


Down down down


Under :)

and i want to get the same out of it:
"This is my new news post


Down down down


Under :)"

------------------------------------------------------------------------------------------------------------
When I type this in the form now and i read it again from the database, i get this:
"This is my new news postDown down downUnder :)"

(no '<br>')


[img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] hope you can help me
thanks

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 20 May 2006 - 12:28 PM

Use the nl2br() function to display data back to your page.

[a href=\"http://ca.php.net/manual/en/function.nl2br.php\" target=\"_blank\"]http://ca.php.net/manual/en/function.nl2br.php[/a]
Legend has it that reading the manual never killed anyone.
My site

#3 walnoot

walnoot
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 26 May 2006 - 04:16 PM

Thanks that worked great :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users