I'm having an issue with register.php.

When I try to run the file on my web server and press submit (no matter the inputs) I get this fatal error message:

( ! ) Fatal error: Call to undefined function query() in  /home/ubuntu/workspace/pset7/public/register.php on line 18

I don't know exactly where query() is defined or what to do. Could this be a permissions issue? Code

2 Answers 2


Are you sure that your directory tree is correct? Do you have in a pset7 directory, two directories, includes and public (and anything else that should be there)? Do you have a file named config.php and a file named functions.php in includes and a file named register.php in public?

If you have those correct, then chmod 711 both directories and chmod 600 all PHP files.

Let me know of the result. Happy Coding!

  • Yea, there was a permissions issue.
    – Simonnnn
    Sep 4, 2016 at 13:36

It looks like this is happenning because somewhere in the pset spec it says that you need to use CS50:: before any query statements(I think it's something to do with the database being run with mysql50, though I am not sure). So for example, instead of saying:

$variable = query(blah blah);

you need to say:

$variable = CS50::query(blah, blah);

Hope this helps.

  • All of my code had this CS50:: prefix.
    – Simonnnn
    Aug 27, 2016 at 23:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .