0

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

<?php
// configuration
require("../includes/config.php"); 

if(isset($_SESSION["id"]))
{
    // get user cash
    $rows = query("SELECT * FROM users WHERE id = ?", $_SESSION["id"]);

I keep getting caught up when I process query in the index part of pset7. Not sure why it is undefined since I am requiring the file that refers to it. Any help would be greatly appreciated. I have been copying and pasting solutions from others to see if I had something buggy in my code, however, even other solutions get caught up at query with the same error!

3

query() is defined in the CS50 PHP library, so you need to put CS50::query(whatever) instead of just query. PHP isn't quite as smart with included libraries as C is apparently. :)

  • Ah, it has to do with classes. CS50:: means calling from inside the CS50 class. I really need to read up more on object oriented programming. Anyway, yeah, that's still what's needed. – Fobok Feb 22 '16 at 21:26

You must log in to answer this question.

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