Storing HTML in database

From: Date: Tue, 02 Oct 2001 22:29:18 +0000
Subject: Storing HTML in database
Groups: php.db 
Request: Send a blank email to php-db+get-12942@lists.php.net to get a copy of this message
Hello, I'm trying to store HTML (that is cut-n-paste from source) into a textarea field on a web page. As it's submitted to the php page that processes it, the database column that it ends up with strips the "<" and ">" out of the html so that it doesn't end up in the source. Example.... I can cut-n-paste... the following into a textarea... --------------original test html code------------------------ <i>this is supposed to be in italics</i> <b>this is supposed to be bold</b> <table> <tr> <td align="left" valign="top">Column 1, Row 1</td> <td align="left" valign="top">Column 2, Row 1</td> </tr> <tr> <td align="left" valign="top">Column 1, Row 2</td> <td align="left" valign="top">Column 2, Row 2</td> </tr> </table> ------------------------------------------------------------- ... and process it with htmlentities() by the receiving php page as it will show... ----original code as received and displayed in php processing page------ <i>this is supposed to be in italics</i> <b>this is supposed to be bold</b> <table> <tr> <td align=\"left\" valign=\"top\">Column 1, Row 1</td> <td align=\"left\" valign=\"top\">Column 2, Row 1</td> </tr> <tr> <td align=\"left\" valign=\"top\">Column 1, Row 2</td> <td align=\"left\" valign=\"top\">Column 2, Row 2</td> </tr> </table> ------------------------------------------------------------------------- Which I can deal with easily enough... but when the same is posted, processed (w/ htmlentities), and retrieved from the MySQL database, I receive the following .... --------------original code as retrieved from database------------------ i this is supposed to be in italics /i b this is supposed to be bold /b table tr td align=\"left\" valign=\"top\" Column 1, Row 1 /td td align=\"left\" valign=\"top\" Column 2, Row 1 /td /tr tr td align=\"left\" valign=\"top\" Column 1, Row 2 /td td align=\"left\" valign=\"top\" Column 2, Row 2 /td /tr /table ------------------------------------------------------------------------ What am I doing wrong? This just can't be rocket science. There's probably something essential that I'm missing. Thanks much.... -- __ _ Tyler Nally / /__ ____ _(_)___ ____ ____ _________ _ tnally@legion.org / / _ \/ __ / / __ \/ __ \ / __ \/ ___/ __ / 317-860-3009 / / __/ /_/ / / /_/ / / / // /_/ / / / /_/ / American Legion Website /_/\___/\__, /_/\____/_/ /_(_)____/_/ \__, / http://www.legion.org /____/ /____/

« previous php.db (#12942) next »