TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-12-2008, 10:19 PM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default how do you insert html into your database?

the html code contains symbols how do you insert that into mysql database witout getting errors?

for example

if i wanted to insert this peice of code into a table how would i insert it witout getting errors :(

Code:
<ul>
<li class="listing">first</li>
<li>second </li>
<li> third</li>
<li class="last">fourth</li>
</ul>
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 09-12-2008, 10:33 PM   #2 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

nm, i figured it out lol

for those of you who want to know how to do it :)
what i did was

i put a textarea box on the page to insert the html into (for testing)
and i did
Code:
$code = urlencode($_POST['txt_code']);
mysql_query("insert into tablename values(null,'$code'");
what that does is it places a buncha %'s into the html code where its needed

then to output it

i did

while($row = mysql_fetcH_assoc--- bla bla all that stuff then
echo urldecode($row['code']);
__________________
no signature set
sarmenhb is offline  
Reply With Quote
The Following User Says Thank You to sarmenhb For This Useful Post:
BJ Duncan (09-13-2008)
Old 09-13-2008, 11:51 AM   #3 (permalink)
The Wanderer
 
BJ Duncan's Avatar
 
Join Date: Sep 2008
Posts: 9
Thanks: 1
BJ Duncan is on a distinguished road
Default

Thanks for this info. I was using the htmlentities() and the html_decode_entity() functions.

What is the difference between the htmlentities function and the urlencode functions?
__________________
Regards,
BJ Duncan
BJ Duncan is offline  
Reply With Quote
Old 09-13-2008, 12:08 PM   #4 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

urlencode just encodes characters that are URL-incompatible. Practically, you would use htmlentities on any output that goes on the screen and is going to be viewed by users. urlencode assumes encoding of URL parts only.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:27 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design