Jump to content

Parse error: syntax error, unexpected T_PUBLIC in … ?


tonsils

Recommended Posts

Hi,

 

I am new to php and trying out this tutorial at :

 

http://css-tricks.com/php-for-beginners-building-your-first-simple-cms/

 

Unfortunately I am getting the following error and can't seem to track down the reason:

 

Parse error: syntax error, unexpected T_PUBLIC in ../simpleCMS.php on line 56

My code for simpleCMS.php is as is in the tutorial link above.

 

FYI, my line 56 is the following line of code in simpleCMS.php

 

    public function display_admin() {

 

Above this line is public function display_public()

 

Can anyone possibly see what I could be doing wrong and again, my code is the same code from the tutorial website and have downloaded the files that came with it?

 

Hoping someone can point me in the right direction.

 

Thanks again.

From what you've posted, it looks like you've opened the  method

 

public function display_public()

 

But you never close it

 

public function display_public()

public function display_admin() {
//code

}

 

Does that look similar to what you have? If so, try either adding a semi-colon after display_public(), failing that, try adding {}

Thanks for getting back to me but I have just posted a snippet of code. I can assure you that all { } are correct and matching.

 

Would be good if someone could try the very same tutorial I listed from css-tricks and see if they also get the same error and perhaps someone who has more experience then me, locate the problem and pls let me know.

 

I really want to learn PHP and by the looks of it, I'm already not doing that great.

 

Thanks.

Hi,

 

Really appreciate you downloading files and getting it running with no problems. As I mentioned, I am new to PHP and trying to get the hang of it.

 

I will post my code tonight - I am in Australia and currently at work.

 

Can't wait to see what I could have done wrong.

 

Will post code later.

 

Thanks again.

T.

Hi,

 

Just want to say thanks for your help but I have also managed to get it going. I have one question though, would the following code arrangement cause any issues when calling mysql_connect as the sample code had it all on one line, i.e.:

 

mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());

 

I had this:

 

public function connect() {
	mysql_connect($this->host,
				  $this->username,
				  $this->password)
		or die("Could not connect. " . mysql_error());

 

Just wondering if the linefeeds/carriage returns when calling this function would cause a T_PUBLIC error?

 

Thanks.

 

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.