dity Posted September 22, 2008 Share Posted September 22, 2008 I'm trying to implement a class file so I don't have to duplicate a lot of code, anyways I keep getting this syntax error and I'm pulling my hair out trying to figure out why.. Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /ActiveUser.class.php on line 5 Here is my ActiveUser.class.php code.. <?php class ActiveUser { public function __construct() { } public function count($username, $password = null, $link = null) { $sql = "SELECT COUNT(*) FROM active_user WHERE username = ".mysql_real_escape_string($username).""; if (!empty($password)) { $sql .= " AND password = ".md5($password).""; } $query = $this->query($sql,$link); return mysql_result($query, 0, 0); } public function insert($username, $password, $link) { $sql = "INSERT INTO active_user VALUES (”,".$username.", ".md5($password).")"; $query = $this->query($sql, $link); } private function query($sql, $link) { $query = mysql_query($sql,$link); if (!$query) { return "problem with sql, ".mysql_error(); } else { return $query; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/ Share on other sites More sharing options...
wildteen88 Posted September 22, 2008 Share Posted September 22, 2008 What version of PHP are you using? You should not be having any problems if you're using PHP5 . However you will get that error with PHP4. PHP4 has very limited OOP support. PHP4 does not support visibility keywords (public, private, protected) nor does it support magic function such as __construct Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-647798 Share on other sites More sharing options...
dity Posted September 22, 2008 Author Share Posted September 22, 2008 im using php 5.. Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-647848 Share on other sites More sharing options...
dity Posted September 23, 2008 Author Share Posted September 23, 2008 has anyone else ran into this problem? Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-648646 Share on other sites More sharing options...
waynew Posted September 23, 2008 Share Posted September 23, 2008 Try <?php class ActiveUser { public function ActiveUser() { } public function count($username, $password = null, $link = null) { $sql = "SELECT COUNT(*) FROM active_user WHERE username = ".mysql_real_escape_string($username).""; if (!empty($password)) { $sql .= " AND password = ".md5($password).""; } $query = $this->query($sql,$link); return mysql_result($query, 0, 0); } public function insert($username, $password, $link) { $sql = "INSERT INTO active_user VALUES (”,".$username.", ".md5($password).")"; $query = $this->query($sql, $link); } private function query($sql, $link) { $query = mysql_query($sql,$link); if (!$query) { return "problem with sql, ".mysql_error(); } else { return $query; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-648649 Share on other sites More sharing options...
discomatt Posted September 23, 2008 Share Posted September 23, 2008 The script executes without error on PHP 5.2.6/Apache 2.2.8 and error_reporting( E_ALL ). Are you SURE you have PHP5? Try executing phpinfo(); It'll tell you right at the top. Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-648653 Share on other sites More sharing options...
dity Posted September 23, 2008 Author Share Posted September 23, 2008 My host is retarded.. you have to rename your php files to .php5 if you want them on php 5.. thanks problem solved.. Quote Link to comment https://forums.phpfreaks.com/topic/125324-solved-error-with-classphp-file/#findComment-648691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.