Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2000121

[PHP-DB] Problem with NULLs and sybase_fetch_row From: Darryl Friesen (Darryl.Friesen <email protected>)
Date: 12/11/00

I've gotr a Digital Unix box running Apache 1.3.12, FreeTDS 0.50, and PHP
4.0.3pl1 (using the sybase-ct libs) talking to our MSSQL server (7.0), and
have noticed a problem with sybase_fetch_row and NULL values. When a NULL
is encountered, the array returned by sybase_fetct_row seems to "inherit"
the last non-NULL value from a previous call to sybase_fetch_row.

For testing purposes I created a small database with 3 columns (a,b,c) with
the following data (columns are varchar 50):

    1 2 3
   10 20 30
 NULL 200 300
 1000 NULL 3000
10000 20000 NULL
        NULL NULL

I've got a bit of code that connects does a "SELECT a,b,c FROM TABLE1", then
uses a while $data = sybase_fetch_array($query) to loop through the results
and dump the data. I get the following results -- notice the repeated
values (i.e. 3000) where the above table has NULL. Empty strings are OK;
it's just NULL that causes a problem.

    1 2 3
   10 20 30
   10 200 300
 1000 200 3000
10000 20000 3000
       20000 3000

Has anyone seen this before? I'd appreciate _any_ suggestions or tips. I
can post my PHP code if people think that's of benefit.

Thanx,

- Darryl

 ----------------------------------------------------------------------
  Darryl Friesen, B.Sc., Programmer/Analyst Darryl.Friesen <email protected>
  Education & Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 ----------------------------------------------------------------------
  "Go not to the Elves for counsel, for they will say both no and yes"

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>