Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/
Share on other sites

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
}

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216954
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216960
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216965
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216968
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216975
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/236737-spot-the-error/#findComment-1216977
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.