php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31681 when using trim(...) loop stops
Submitted: 2005-01-24 21:42 UTC Modified: 2005-02-02 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: joesterg at hotmail dot com Assigned:
Status: No Feedback Package: Strings related
PHP Version: 5.0.3 OS: Windows 2000 Server
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joesterg at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-01-24 21:42 UTC] joesterg at hotmail dot com
Description:
------------
Whenever trim(...) is used on the 
  $value=trim($colstr->value);
line, the loop stops. 
However, splitting the line in two:
  $value=$colstr->value;
  $value=trim($value);
makes the loop work as expected...

Reproduce code:
---------------
$this->DBResult=$this->DBCon->Execute($sqlQuery);
$num_columns = $this->DBResult->Fields->Count();
$this->DBResultSet=null;
        for($i=0; $i < $num_columns; $i++) {
          $colstr=$this->DBResult->Fields($i);
          $name=$colstr->Name;
          toLog("DB_ADO.query","3.0: i=".$i.", Fields=".$colstr."/".$name.", num_columns=".$num_columns);
          $value=trim($colstr->value);
          toLog("DB_ADO.query","3.1: i=".$i.", Fields=".$colstr."/".$name."/".$value.", num_columns=".$num_columns);
          $this->DBResultSet[$rowcount][$name]=$value;
          toLog("DB_ADO.query","3.2: this->DBResultSet[rowcount][name]=".$this->DBResultSet[$rowcount][$name]);
        }


Expected result:
----------------
DBCon is an ADO connection to SQL Server 2000.

I expect to have the code loop through the columns found in the query, assigning each column a value in the DBResultSet array.

Seeing the following in the log:

2005.01.24-21.43:02***DB_ADO.query***1: select statement
2005.01.24-21.43:02***DB_ADO.query***2: num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.0: i=0, Fields=4/id, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=0, Fields=4/id/4, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=4
2005.01.24-21.43:02***DB_ADO.query***3.0: i=1, Fields=jqj/username, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=1, Fields=jqj/username/jqj, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=jqj
2005.01.24-21.43:02***DB_ADO.query***3.0: i=2, Fields=8ad8757baa8564dc136c1e07507f4a98/password, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=2, Fields=8ad8757baa8564dc136c1e07507f4a98/password/8ad8757baa8564dc136c1e07507f4a98, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=8ad8757baa8564dc136c1e07507f4a98
2005.01.24-21.43:02***DB_ADO.query***3.0: i=3, Fields=J?rgen ?stergaard/realname, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=3, Fields=J?rgen ?stergaard/realname/J?rgen ?stergaard, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=J?rgen ?stergaard
2005.01.24-21.43:02***DB_ADO.query***3.0: i=4, Fields=jorgen.ostergaard@endjin.com/email, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=4, Fields=jorgen.ostergaard@endjin.com/email/jorgen.ostergaard@endjin.com, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=jorgen.ostergaard@endjin.com
2005.01.24-21.43:02***DB_ADO.query***3.0: i=5, Fields=-/phone, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=5, Fields=-/phone/-, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=-
2005.01.24-21.43:02***DB_ADO.query***3.0: i=6, Fields=-/fax, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=6, Fields=-/fax/-, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=-
2005.01.24-21.43:02***DB_ADO.query***3.0: i=7, Fields=DEA/companycode, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=7, Fields=DEA/companycode/DEA, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=DEA
2005.01.24-21.43:02***DB_ADO.query***3.0: i=8, Fields=ADMIN/role, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=8, Fields=ADMIN/role/ADMIN, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=ADMIN
2005.01.24-21.43:02***DB_ADO.query***3.0: i=9, Fields=EN/languagecode, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.1: i=9, Fields=EN/languagecode/EN, num_columns=10
2005.01.24-21.43:02***DB_ADO.query***3.2: this->DBResultSet[rowcount][name]=EN


Actual result:
--------------
From the log:
2005.01.24-21.41:15***DB_ADO.query***1: select statement
2005.01.24-21.41:15***DB_ADO.query***2: num_columns=10
2005.01.24-21.41:15***DB_ADO.query***3.0: i=0, Fields=4/id, num_columns=10


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-24 21:50 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
 [2005-01-24 21:54 UTC] joesterg at hotmail dot com
Ok, I can provide that, but you also need a setup with a SQL Server 2000 to replicate this fully...
 [2005-01-25 15:06 UTC] sniper@php.net
Please read the comment again:

"no external resources" 

If you can't come up with an isolated test case we can't fix anything.

 [2005-02-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC