Hello:
  
I've got a table with 34 fields:
(best viewed using a non-proportional font)
  
mysql> describe contacts;
+-----------------+------------------+------+
| Field           | Type             | Null |
+-----------------+------------------+------+
| CustNo          | int(10) unsigned |      |
| CoName          | varchar(50)      |      |
| Add1            | varchar(50)      | YES  |
| Add2            | varchar(50)      | YES  |
| Add3            | varchar(50)      | YES  |
[ . . . ]
| Relationship    | set('C','V','F') | YES  |
| Website         | varchar(254)     | YES  |
| Notes           | mediumtext       | YES  |
+-----------------+------------------+------+
34 rows in set (0.16 sec)
  
In the offending php script:
  
[ . . . ]
// Turn on strict error reporting.
error_reporting(E_ALL)
[ . . . ]
$row =  mysql_fetch_array($result,MYSQL_BOTH)
  
// Test if field is NULL
if ($row["Add1"]) {
    // do stuff
   }
  
if ($row["Add2]) {
    // do stuff
   }
  
[Repeat 'if' check 28 more times for other fields, all of which work
without problem or warnings.]
  
if ($row["Website"]) {
    // do stuff
   }
[ . . . ]
  
if ($row["Notes"]) {
    // do stuff
   }
[ . . . ]
In the test data record, most of the fields are NULL.  The construct
above is only a fragment; I test 31 of the 34 fields, then I do things
only if they contain data.  All of the tests work fine, EXCEPT the
"Website" field (the last field in the table).  On test records in
which the "Website" field contains a string (even an empty string), it
works fine
  
BUT!  If the field is NULL, php spits out this:
  
"Warning: Undefined index: Website in
f:\website\pmaco\admin\contacts1.php on line 241"
  
If I substitue a numeric index (eg '$row[33]) for the associative one
(eg $row["Website"]), no problem.  That is:
  
        if ($row[33]) {etc.}
  
works fine, even with a NULL field.
  
And, if I change the offending php row to:
        if ($row["website"]) 
  
(lowercase "w")
I still get:
  
"Warning: Undefined index: website in 
f:\website\pmaco\admin\contacts1.php on line 241"
  
Thoughts/ideas?
  
MySQL 3.23.32 (latest GA available for my platform)
PHP 4.04pl1
  
Regards,
Al S.
  



-- 
* Hillman & other Rootes Group manuals online: http://asavage.fdns.net/Hillman
* Ford Falcon manuals online:                  http://FalconFAQ.fdns.net

Just moving fast is not the same as getting somewhere.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to