tonsils Posted April 26, 2010 Share Posted April 26, 2010 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. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 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 {} Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1048632 Share on other sites More sharing options...
tonsils Posted April 26, 2010 Author Share Posted April 26, 2010 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. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1048650 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 I just downloaded the files from that tutorial, and no error shows up. Can you post your OWN code please. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1048679 Share on other sites More sharing options...
tonsils Posted April 26, 2010 Author Share Posted April 26, 2010 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. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1049029 Share on other sites More sharing options...
tonsils Posted April 27, 2010 Author Share Posted April 27, 2010 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. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1049322 Share on other sites More sharing options...
Ken2k7 Posted April 27, 2010 Share Posted April 27, 2010 Nope, white spaces do not affect the code, unlike in Python. Link to comment https://forums.phpfreaks.com/topic/199787-parse-error-syntax-error-unexpected-t_public-in-%E2%80%A6/#findComment-1049376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.