JO'Donnell JO'Donnell - 3 months ago 363
MySQL Question

PHP 7, Fatal error: Constant expression contains invalid operations

I am building a login sequence for a website that I am designing for a school project with MySQL and PHP7 (which I am relatively new to). I need some help understanding what this error means and how I can resolve the issue:

Fatal error: Constant expression contains invalid operations in C:\Abyss Web Server\htdocs\login_tools.php on line 19

Here is the line of code for a function which ensures a login has succeeded and retrieves the associated user details:

function validate($dbc, $email=",$pwd=")

Answer

As you can see by the line of code you posted you used a single double quote in the function declaration. If you look closely you'll see that ,pwd=" is all in red because of the single double quote after $email=

Either change the double quote to 2 single quotes or add another double quote.

function validate($dbc, $email='',$pwd='')

OR

function validate($dbc, $email="",$pwd="")
Comments