Jump to content

Spot the error


hoponhiggo

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.