Re: why does compiler complain
| From: | Christian Reiniger | Date: | Wed, 20 Dec 2000 23:41:07 +0000 |
| Subject: | Re: why does compiler complain | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31337@lists.php.net to get a copy of this message | ||
On Wednesday 20 December 2000 22:52, Mike Wright wrote:
> // the query
> $resource_id = mysql_query( "SELECT extra FROM extras" );
>
> // the loop
> while( $row = mysql_fetch_array( $resource_id ))
> {
> $some_var = $row[_EXTRA_]; // <--- throws error
> }
> The error is:
> Warning: undefined index: extra in test.php on line 15.
>
> This is very simple code. Can anyone explain the warning?
I'd say the $row array simply doesn't contain an entry with index "extra"
Try
$row = mysql_fetch_array( $resource_id, MYSQL_ASSOC )
although that shouldn't be needed...
You should also check whether the query actually returns data.
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offence.
- Edsger W. Dijkstra