Bug #17969 Updated: Immediately getting an array element fails with a function
| From: | sander@php.net | Date: | Tue, 25 Jun 2002 14:26:52 +0000 |
| Subject: | Bug #17969 Updated: Immediately getting an array element fails with a function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12046@lists.php.net to get a copy of this message | ||
ID: 17969
Updated by: sander@php.net
Reported By: atalabac@pop500.gsfc.nasa.gov
-Status: Won't fix
+Status: Bogus
-Bug Type: Feature/Change Request
+Bug Type: Arrays related
Operating System: Windows 2000
PHP Version: 4.2.1
New Comment:
Expected behaviour.
There was a feature request about this but IIRC this won't be changed.
Not a bug -> bogus.
Previous Comments:
------------------------------------------------------------------------
[2002-06-25 10:26:44] cynic@php.net
this has been requested more than once; I wrote one of the feature
requests;
and the outcome was that PHP won't support this syntax.
closing
------------------------------------------------------------------------
[2002-06-25 09:31:05] atalabac@pop500.gsfc.nasa.gov
I have this script:
<?
// Load configuration
@((int)require('config.php')) or die('!Unable to load server
configuration file.');
// Connect to db
$dbhandle = mysql_connect($dbserver, $dbuser, $dbpass) or die('!Unable
to connect to MySQL server.');
mysql_select_db($dbname) or die('!Unable to select Garnet database.');
$variable = $_GET['variable'];
$result = mysql_query("SELECT value FROM settings WHERE
variable=$variable");
if (!$result)
{
echo '!Failed to get variable value';
}
else
{
echo mysql_fetch_row($result)[0];
}
mysql_close($dbhandle);
?>
It appears to work perfectly fine except for line 17: "echo
mysql_fetch_row($result)[0];". In every other language I've used this
is perfectly acceptable: return the first element of the array returned
by mysql_fetch_row($result). However I get this error:
Parse error: parse error, unexpected '[', expecting ',' or ';' in
page.php on line 17
Is the only workaround to do this?
$s = mysql_fetch_row($result);
echo $s[0];
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17969&edit=1