|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-25 10:26 UTC] cynic@php.net
[2002-06-25 10:26 UTC] sander@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
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];