Re: php3-php4 mysql problem with nl2br coding
| From: | Jim Lucas | Date: | Fri, 23 Nov 2001 20:23:26 +0000 |
| Subject: | Re: php3-php4 mysql problem with nl2br coding | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14561@lists.php.net to get a copy of this message | ||
one way to get rid of the problem is to just not use the nl2br when you are
inserting the data and instead
change your ereg to look for the \n in the body and change that into ""
Jim
----- Original Message -----
From: "Terry Romine" <eatrom@blazing-trails.com>
To: <php-db@lists.php.net>
Sent: Friday, November 23, 2001 12:04 PM
Subject: [PHP-DB] php3-php4 mysql problem with nl2br coding
> I seem to have run into a strange bug where when I enter text through a
> form, and use the nl2br call in PHP, instead of getting "<BR>" I get
> "<BR />" and then my parsing fails on the display side (where I use
> ereg_replace("<br>","", $string) to clean up the breaks.
>
> sample code:
>
> Entry Form
> $c_title = addslashes($c_title);
> $c_content = addslashes(nl2br($c_content));
> $sql = "update $tableName set
> c_title='$c_title',
> c_content='$c_content'
> where c_id=$itemID";
> if(!($result=mysql_query($sql, $link))) {
> echo("ERROR 109 $sql<br>\n");
> exit();
> }
>
> and display
>
> $sql = "select * from $tableName";
> $result = mysql_query($sql) or die("ERROR: $sql");
> while ($row = mysql_fetch_object($result)) {
> echo("<tr>");
> $myTitle[$j] = $row->c_title;
> $myContent =
> stripslashes(ereg_replace("<br>","",$row->c_content));
> echo("<td colspan=2><hr><br>
> <p><font size='2' face='Verdana, Arial, Helvetica, sans-
> serif'><b>$myTitle[$j]</b></font></p>
> <p><font size='2' face='Verdana, Arial, Helvetica, sans-
> serif'>$myPhoto1 $myContent $myPhoto2</font></p>
> $myPhoto3
> <hr></td></tr>");
> }
>
>
> --
> 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
>
>