siannone siannone - 7 months ago 43
PHP Question

PHP class not found but it's included

I'm including a PHP class with

require_once($ENGINE."/classUser.php");


but when the code is executed i receive this error:


Fatal error: Class 'User' not found in
C:\xampp\htdocs\WebName\resources\engine\ajax\signup.php on line 12


I still can't figure out what's the problem. I'm 99% sure it's correct.

The "$ENGINE" is correct, and the class is correct too (Netbeans suggests me class methods and variables).

signup.php:

<?php

/* Created on: 13/12/2011
* Author:
*
* Description: User signup procedure.
*/

require_once("../settings.php");
require_once($ENGINE."/classUser.php");

$user = new User();
$user->createUser($_POST["username"], $_POST["email"], $_POST["password"]);


?>


classUser.php:

<?php

/* Created on: 13/12/2011
* Author:
*
* Description: This class manages users.
*/

require_once("settings.php");
require_once($LIBRARY."/cassandraphp/cassandra.php");

class User {

public function createUser($username, $email, $password){
$cassandra = Cassandra::createInstance($CASSANDRASERVER);
$cassandra->set(
"user.".$username,
array(
'ID' => uniqid(),
'Username' => $username,
'Email' => $email,
'Password' => $password
)
);
}
}

?>

Answer

First of all check if $ENGINE."/classUser.php" is a valid name of existing file. Try this:

var_dump(file_exists($ENGINE."/classUser.php"));