JO'Donnell JO'Donnell - 1 year ago 1225
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 Source

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='')


function validate($dbc, $email="",$pwd="")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download