I have the following code:
$url = @mysql_fetch_array(mysql_query("SELECT url FROM dl LIMIT 1"));
$url = $url[0];
but I would rather use it as:
$url = @mysql_fetch_array(mysql_query("SELECT url FROM dl LIMIT 1"))[0];
why do I get error for the second one because seems right syntax to me? Or do I miss something?
PHP Parse error: syntax error, unexpected '[' in settings.php on line 52
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial. Also, don't use@. It's a bad coding habbit to just hide errors.mysql_any more. Will we get people that are smart enough to switch to PDO/MySQLi with prepared statements or will everyone simply do a search/replace frommysql_tomysqli_and keep all their insecure code?