RE: [PHP-DB] Storing HTML in database

From: Date: Wed, 03 Oct 2001 00:39:48 +0000
Subject: RE: [PHP-DB] Storing HTML in database
Groups: php.db 
Request: Send a blank email to php-db+get-12947@lists.php.net to get a copy of this message
try using the htmlspecialchars() function instead - works for me :) // -----Original Message----- // From: Nally, Tyler G. [mailto:tnally@legion.org] // Sent: Wednesday, 3 October 2001 6:29 AM // To: 'php-db@lists.php.net' // Subject: [PHP-DB] Storing HTML in database // // // 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 /____/ /____/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#12947) next »