RE: [PHP] why does php issue this warning notice?
| From: | Maciek Uhlig | Date: | Fri, 22 Dec 2000 21:54:23 +0000 |
| Subject: | RE: [PHP] why does php issue this warning notice? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31636@lists.php.net to get a copy of this message | ||
there is no 'extra' element in $row delivered by MySQL, I suppose.
Maciek
> -----Original Message-----
> From: mike@orb3.theorb.net [mailto:mike@orb3.theorb.net]On Behalf
> Of php@theOrb.net
> Sent: Wednesday, December 20, 2000 12:31 AM
> To: php-general@lists.php.net
> Subject: [PHP] why does php issue this warning notice?
>
>
> 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
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>