Can't figure out this ereg problem
Posted: Fri Dec 27, 2002 9:58 am
Hi,
In my Admin section I use a 3 files to insert, edit and delete "items" into the database.
item_insert.php: a simple form that is posted to item.php
item_edit.php: a form that retrieves the data from the selected item
item.php: contains the logic for inserting, updating and deleting an item.
When I use "caridge return" when inserting a new item it converts it to < /br> which is ok.
But the strange phenomenon I'm experiencing is that when I edit the item afterwards and save it into the database all the existing < /br> are duplicated.
What am I doing wrong ??
Here is the code I use in for the textarear in items_insert.php:
Here is the code I use in item.php in a switch-statement, before the data is inserted or updated in the database:
Some help would be much appreciated !
Thanks in advance,
Gijs
In my Admin section I use a 3 files to insert, edit and delete "items" into the database.
item_insert.php: a simple form that is posted to item.php
item_edit.php: a form that retrieves the data from the selected item
item.php: contains the logic for inserting, updating and deleting an item.
When I use "caridge return" when inserting a new item it converts it to < /br> which is ok.
But the strange phenomenon I'm experiencing is that when I edit the item afterwards and save it into the database all the existing < /br> are duplicated.
What am I doing wrong ??
Here is the code I use in for the textarear in items_insert.php:
Code: Select all
// Conversion of end_of_page-marks in news_main to HTML end_of_page-marks
$_POSTї'item_text'] = nl2br($_POSTї'item_text']);
$_POSTї'item_text'] = eregi_replace("\n", "", $_POSTї'item_text']);Here is the code I use in item.php in a switch-statement, before the data is inserted or updated in the database:
Code: Select all
// Conversion of the <br>-tags tot end_of_line
$itemsї'item_text'] = eregi_replace('<brїї:space:]]$/?її:space:]]*>', "/n", $itemsї'item_text']);Thanks in advance,
Gijs