Can anyone figure out this php error message???

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)
<?php
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

FairyBusinessAsked:
Who is Participating?
 
4e4enConnect With a Mentor Commented:
Oh and you have also forgot to close function "private function has_attribute($attribute)" it should have an "}" after line 53.
return array_key_exists($attribute, $object_vars);

Open in new window

0
 
4e4enCommented:
try to change 63. line to

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

Open in new window

0
 
FairyBusinessAuthor Commented:
I did and said this:


Parse error: syntax error, unexpected T_PUBLIC in /hermes/web09c/b2950/moo.auroriellacom/includes/user.php on line 63
0
 
FairyBusinessAuthor Commented:
thanks, I totally missed that!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.