FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to save HTML in Databases wise ly ?





Philip
How to save HTML in Databases wise ly ?

I need to create a php script, that user can write down a HTML code
and save it to MySQL Databases

But the tag of HTML is very2x much, and i am fraid one of them could
harm my website T_T, is there any gud idea for doing this thing ?

Is there any php function that checking html function that right and wont error, also not harm my website ?

Thanks.
ganbate
use htmlspecialchars function.
it will convert all the html tag into a special character.
please read about it from the php manual or other source.
yjwong
You could use something like a BLOB datatype. This will enable you to store up to 65536 characters if I'm not wrong. If you want more, just split the HTML into many chunks and store them separately. If anyone has a better idea, please post.
kv
A tip here. You can gzip the html content and put in your database. When sending html to browser, you need to set appropriate header saying it is gzipped content. You don't have to gunzip. Browser will do the job on client side. It also makes web page rendering faster.
Philip
kv wrote:
A tip here. You can gzip the html content and put in your database. When sending html to browser, you need to set appropriate header saying it is gzipped content. You don't have to gunzip. Browser will do the job on client side. It also makes web page rendering faster.


How !!? ?? ?? ? u just give me more question on my topic, damm.... --"
u better teach me with your owesome knowledge. Smile
kv
Just call this before sending gzip contents to browser
Code:

header('Content-Encoding: x-gzip');

in your php. Rest of the things are automatically taken care.
Philip
kv wrote:
Just call this before sending gzip contents to browser
Code:

header('Content-Encoding: x-gzip');

in your php. Rest of the things are automatically taken care.

so if on my php as long i add this header('Content-Encoding: x-gzip');
all my transfer rate from server to client will more faster ?
am i right ?
and it support to all txt inside php ?
and i just to

<?
header('Content-Encoding: x-gzip');
echo $contenthere;
?>

like that ?

thanks
kv
Yes, if your $contenthere is gzipped html i.e., you saved the gzipped html in database sometime, retrieved it and are echo-ing it. If it is normal html and you want apache-php to take care of gzipping it on your behalf, you have to put

Code:
ob_start("ob_gzhandler");


at the beginning of each of your php file (inside <? ?> tag, of course)

and

Code:
ob_flush();


at the end.

And yes, it makes transfer rate of pages much faster.
Related topics
Basic HTML Introduction
How To : Improve Your PHP Programming
Save webpage source into javascript variable
html editor?
HTML Problem
kgcole
hide html code ..
need help with bbcode.....
Web form to save HTML table as spreadsheet
Tutorial: How to write HTML without ANY code whatsoever!
Save as .html or .php
FREE Powerfull Software for Windows
Escaping Strings For Data Insertion
Am I getting bad neighbourhood?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.