Stripping newline chars?
| From: | Lauri Vain | Date: | Mon, 20 Nov 2000 17:31:50 +0000 |
| Subject: | Stripping newline chars? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26296@lists.php.net to get a copy of this message | ||
Hello,
I have a problem and I can't seem to get it fixed :-(
My database looks like this:
db_items_id | db_price | db_desc
Now, the price has lots of newline chars at the *end* which aren't supposed to
be there any more, I need to strip them. The number of them varies.
My current script looks like this(yes, it's not very resource effective but I
can afford it at the moment). It doesn't work, can't see the problem:
**************start***************
$db = mysql_connect("localhost","root","pass");
mysql_select_db("skriptid",$db);
$vastus_query=mysql_query("SELECT db_price,db_items_id FROM kiba_items");
while ($vastus = mysql_fetch_array($vastus_query))
{
$mypattern="(\n)$";
$blah=$vastus["db_price"];
$myid=$vastus["db_items_id"];
for($i=1;$i=50;$i++)
{ $bal=eregi_replace($mypattern,"",$blah); }
echo nl2br($bal)."<br>";
$sql = "UPDATE kiba_items SET db_price='$bal' WHERE id=$myid";
$update_cart = mysql_query($sql);
}
**************end***************
Thanks in advance.
Yours truly,
Lauri Väin