hoponhiggo Posted May 18, 2011 Share Posted May 18, 2011 Can anybody see where the error is here: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/.../functions.php on line 10 <?php //Wall_Updates class Wall_Updates { // Updates public function Updates($uid) { $query = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages M, users U WHERE M.uid_fk=U.uid and M.uid_fk='$uid' order by M.msg_id desc") or die(mysql_error()); while($row=mysql_fetch_array($query)) $data[]=$row; return $data; } I have only posted the first few lines of code becouse apparently the error should be before line 10? Please let me knwo if you need the full code Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/ Share on other sites More sharing options...
TheSky Posted May 18, 2011 Share Posted May 18, 2011 you are missing } at the end? //Wall_Updates class Wall_Updates { // Updates public function Updates($uid) { $query = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages M, users U WHERE M.uid_fk=U.uid and M.uid_fk='$uid' order by M.msg_id desc") or die(mysql_error()); while($row=mysql_fetch_array($query)) $data[]=$row; return $data; } //close } Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216954 Share on other sites More sharing options...
PFMaBiSmAd Posted May 18, 2011 Share Posted May 18, 2011 You still using php4, but trying to use php5 OOP syntax. Time to upgrade your php version, because the end of life of php4 was over 4 years ago. Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216955 Share on other sites More sharing options...
pornophobic Posted May 18, 2011 Share Posted May 18, 2011 you are missing } at the end? This. You didn't close your class. Edit: Also, You still using php4, but trying to use php5 OOP syntax. Time to upgrade your php version, because the end of life of php4 was over 4 years ago. Didn't they recently retire PHP 5.2 as well? I know there is a few differences in OOP with 5.3 and 5.2. http://www.php.net/archive/2011.php#id2011-03-17-1 Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216960 Share on other sites More sharing options...
PFMaBiSmAd Posted May 18, 2011 Share Posted May 18, 2011 I have only posted the first few lines of code ...... Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216961 Share on other sites More sharing options...
hoponhiggo Posted May 18, 2011 Author Share Posted May 18, 2011 Yes, the class is closed at the end of the script. I dont undesrtand the version problem tho. Is this the version of the php software my host uses, or is this down to the language being used? I should say i am new to php and this code is part of a script written by somebody else. Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216965 Share on other sites More sharing options...
PFMaBiSmAd Posted May 18, 2011 Share Posted May 18, 2011 The public keyword is specific to php5 OOP syntax and produces that error when used on php4. Your web host should have provided a way of upgrading your account to the latest php5 version, because the end of life and end of support for php4 was over 4 years ago. Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216968 Share on other sites More sharing options...
pornophobic Posted May 18, 2011 Share Posted May 18, 2011 The public keyword is specific to php5 OOP syntax and produces that error when used on php4. Eep! Don't I feel a bit sheepish now. Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216973 Share on other sites More sharing options...
hoponhiggo Posted May 18, 2011 Author Share Posted May 18, 2011 Ok Thanks Ill try and contact the host admin and ask about upgrading the PHP version. If i encounter problems, are there any work arounds so i can avoid using the Public function? Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216974 Share on other sites More sharing options...
PFMaBiSmAd Posted May 18, 2011 Share Posted May 18, 2011 If you have a OOP class that was written for php5, there are likely a ton of things it is doing that are not compatible with php4. The workaround would be to not use php4, because the end of life and end of support for it was over 4 year ago. Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216975 Share on other sites More sharing options...
hoponhiggo Posted May 18, 2011 Author Share Posted May 18, 2011 Hang on....I feel like a proper muppet now!! I have just been looking at my PHP settings in CPANEL and discovered a setting to switch between PHP4 and PHP5. I switched to 5 and its now working! Surely this should be set to the latest version by default. Sorted now tho. Many thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216977 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.