We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Can anyone figure out this php error message???

Medium Priority
Last Modified: 2012-08-13
Error messages are driving me crazy tonight.  This is my latest one:

Parse error: syntax error, unexpected T_FUNCTION, expecting T_VARIABLE in /hermes/web09c/b2950/moo.auroriellacom/includes/user.php on line 63

What does it mean by it was expecting a variable instead of a function??  (I did have the function as public but it didn't like that so I took that away)
require_once 'includes/database.php';

class User{ 

public $id;
public $username;
public $hash_password;
public $first_name;
public $last_name;

// Common Databaes Methods

protected static $table = "users";
private $object;

public static function find_all() {
	return self::find_by_sql("SELECT * FROM " . self::$table);
public static function find_by_id($id=0) {
	global $database;
	$result = self::find_by_sql("SELECT * FROM  " . self::$table . " WHERE id={$id} LIMIT 1");
	return !empty($result) ? array_shift($result) : false; //array_shift pulls the first item out
public static function find_by_sql($sql="") {
	global $database;
	$result = $database->query($sql);
	$object_array = array();
	while ($row = $database->fetch_array($result)) {
		$object_array[] = self::instantiate($row);
	return $object_array; // Must return an array!
private static function instantiate($record) {
	$class_name = get_called_class();
	$object = new $class_name; // Here is where it starts a new class for itself
	foreach($record as $attribute => $value) {
		if($object->has_attribute($attribute)) {
			$object->$attribute = $value;
	return $object;

// Unique to User

private function has_attribute($attribute) {
	// get_object_vars returns an associative array with all attributes
	// (including private ones) as the keys and their current value as the value
	$object_vars = get_object_vars($this);
	// We don't care about the value, we just want to know if the key exists
	// Will return true or false
	return array_key_exists($attribute, $object_vars);

function full_name() {
	if(isset($this->first_name) && isset($this->last_name)) {
		return $this->first_name . " " . $this->last_name;
	else {
		return "";
static function authenticate($username="", $hash_password="") {
	global $database;
	$username = $database->clean_strings($username);
	$hash_password = $database->clean_strings($hash_password);
	$sql = "SELECT * FROM users ";
	$sql .= "WHERE username = '$username' ";
	$sql .= "AND hash_password = '$hash_password' ";
	$sql .= "LIMIT 1";
	$result = self::find_by_sql($sql);
	return !empty($result) ? array_shift($result) : false; //array_shift pulls the first item out

} // End class User

Open in new window

Watch Question

try to change 63. line to

public static function authenticate($username, $hash_password) {

Open in new window


I did and said this:

Parse error: syntax error, unexpected T_PUBLIC in /hermes/web09c/b2950/moo.auroriellacom/includes/user.php on line 63
Unlock this solution and get a sample of our free trial.
(No credit card required)


thanks, I totally missed that!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.