Re: removing appended chars - please help, quite urgent
| From: | Adriaan Nel | Date: | Thu, 13 Mar 2003 10:03:13 +0000 |
| Subject: | Re: removing appended chars - please help, quite urgent | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139473@lists.php.net to get a copy of this message | ||
Thanks, I tried the trim function and it solves most of my problems, but I
still get duplicates........it's so weird, could any1 please just quickly
check through these lines of code and tell me if you see anything thats
wrong....
The records in the dbase are uploaded with another php file, which does just
that, no problem over there....this problem is given even if I upload the
same file to the dbase, it's then supposed to not display anything on
screen, cause all records exists allready, but it displays a whole lists of
supposedly new records...??
Here is the code that's giving the problem:
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++
+++++++++++++++++++++ checking for new records, not yet in dbase...
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++*/
$lines = file ('../includes/new1.csv');
foreach ($lines as $line_num => $line) {
list($npr_nr,$npr_exvat,$npr_desc) = explode(",",$line);
$npr_nr = trim($npr_nr, " ");
$query = "SELECT product_id, product_nr from products";
$currentprs = mysql_query ($query, $db_connection) or die (mysql_error());
while (list ($currentprs_id, $currentprs_nr) = mysql_fetch_row
($currentprs))
{
if ($npr_nr == $currentprs_nr) {
mysql_query ("DELETE from tmpprods where product_nr =
'$currentprs_nr'",$db_connection) or die (mysql_error());
} // end if
} // end while
} // end foreach
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++
+++++++++++++++++++++ Finish checking for new records, not yet in dbase...
+++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++*/
Thanks again
Adriaan
"- Edwin" <copperwa11s@yahoo.co.jp> wrote in message
news:JT20030313180449.606006453@yahoo.co.jp...
> Hi,
>
> "Adriaan Nel" <adriaan@nellen.co.za> wrote:
>
> > Do any1 know how I can check for spaces here,
> > and remove them if present????
>
> http://www.php.net/manual/en/function.trim.php ?
> http://www.php.net/manual/en/function.rtrim.php ?
> http://www.php.net/manual/en/function.lrim.php ?
>
> - E
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/
>