why does php issue this warning notice?

From: Date: Tue, 19 Dec 2000 23:31:06 +0000
Subject: why does php issue this warning notice?
Groups: php.general 
Request: Send a blank email to php-general+get-31087@lists.php.net to get a copy of this message
Hello everybody, I have error reporting in PHP.INI set to E_ALL. (Enforces good programming habits) The following code generates the lowest level warning of "notice". Warning: Undefined index: extra in /test.php on line 19 The code works well. I just don't understand why I get this particular notice from the PHP compiler. Environment is PHP 4.02, MySQL 3.23.15-alpha, RHLinux 6.1 This small snippet recreates the warning <?php // establish database connection include( "connect" ); connect(); // define column names as constants define( "_USER_ID_", "user_id" ); define( "_EXTRA_", "extra" ); $select = (" SELECT u.user_id, e.extra FROM users u, extras e WHERE u.user_id = e.user_id "); // do nothing loop for testing $resource_id = mysql_query( $select ); while( $row = mysql_fetch_array( $resource_id )) { $pid = $row[_USER_ID_]; $extra = $row[_EXTRA_]; <--- notice is here } print "Done!" ; ?> If anyone can explain _why_ this happens I'd be most grateful. I've gone off list. Please CC me in your reply. Thanks in advance. Mike Wright

« previous php.general (#31087) next »