Monday 23 October 2017

php - Parse error: syntax error, unexpected '[' with mysql_fetch_assoc I think

I have a client who's hosting was changed to a new hosting
server. In the past they had someone build them a small database project which worked
before, but is no longer working in the new hosting environment. Naturally, I didn't
have anything to do with the scripts and the original coder is telling them he it too
busy to look at it.



The section failing is this
line of code.



$registerquery =
mysql_query("INSERT INTO users (".implode(array_keys($vals), ', ').")
VALUES('".implode(array_values($vals), "', '")."')");
if ($registerquery)
{

$new_user_id = mysql_fetch_assoc(mysql_query("SELECT id FROM
users WHERE email = '$email'"))['id'];
log_in($new_user_id);

...


With the specific
line the error is pointing to
being:



$new_user_id =
mysql_fetch_assoc(mysql_query("SELECT id FROM users WHERE email =
'$email'"))['id'];



The
error is



Parse error: syntax
error, unexpected '[' in ...



pointing to the
specific line with the mysql_fetch_assoc in it which is what is having the syntax error.



Someone have a suggestion on what I could do to
fix it.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...