Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Problems rebuilding database


Reply

6 Posts   2657 Views

Avatar
dwainwillis

22 May 2009 at 8:55am Community Member, 5 Posts

So I'm really new to SilverStripe and I'm sure my question is probably (hopefully) an easy one. I trying to work my way through the tutorials and unfortunately, I can't make my way past the first one. My problem is when I copy/paste the code for the HomePage.php file and save it into the "mysite/code/" directory it seems to break the site. I perform the database rebuild command "http://localhost:8888/dev/build?flush=1" (I'm using MAMP Pro on a Mac running OS X.5) and it seems to freeze up halfway through the creating database run. I'm not sure if there is a specific change I need to make to MAMP for SilverStripe to work properly. Below is the information displayed on the screen when performing the rebuild.
Building Database

Creating database tables

PageComment
SiteTree
Field SiteTree.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Field SiteTree_Live.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Field SiteTree_versions.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Email_BounceRecord
QueuedEmail
File
Group
LoginAttempt
Member
MemberPassword
Permission
Widget
WidgetArea
EditableCheckboxOption
EditableDropdownOption
EditableFormField
EditableRadioOption
SubmittedForm
SubmittedFormField
Page
GhostPage
ArticleHolder
ArticlePage

Avatar
dwainwillis

22 May 2009 at 8:59am Community Member, 5 Posts

Sorry, I forgot to mention that once I've attempted the rebuild, the site no longer works at all. I get a blank screen. I turned on the error reporting for PHP and it reports an T_sytax error on line 6. here is the code from the HomePage.php file.

<?php
/**
* Defines the HomePage page type
*/
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
}
class HomePage_Controller extends Page_Controller {
   function init() {
   parent::init();
}
?>

Avatar
Willr

22 May 2009 at 1:29pm Forum Moderator, 5511 Posts

T_sytax error on line 6

And it was line 6 of HomePage.php? not Page.php?

Avatar
dwainwillis

22 May 2009 at 2:02pm Community Member, 5 Posts

Below is the output from the rebuild attempt: (below that is the actual HomePage.php code)

Environment Builder (formerly db/build)
http://localhost:8888/

dev→ build
Building Database

Creating database tables

PageComment
SiteTree
Field SiteTree.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Field SiteTree_Live.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Field SiteTree_versions.ClassName: changed to enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','HomePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ArticleHolder','ArticlePage','ErrorPage','RedirectorPage','VirtualPage','UserDefinedForm') character set utf8 collate utf8_general_ci default 'SiteTree')
Email_BounceRecord
QueuedEmail
File
Group
LoginAttempt
Member
MemberPassword
Permission
Widget
WidgetArea
EditableCheckboxOption
EditableDropdownOption
EditableFormField
EditableRadioOption
SubmittedForm
SubmittedFormField
Page
GhostPage
ArticleHolder
ArticlePage

Parse error: syntax error, unexpected T_CLASS in /Applications/MAMP/htdocs/silverstripe/SilverStripe-v2.3.1/mysite/code/HomePage.php on line 6

Here is the HomePage.php file:

<?php
/**
* Defines the HomePage page type
*/
 
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
 
}
 
class HomePage_Controller extends Page_Controller {
   
}
?>

Avatar
WildCat

23 May 2009 at 6:06am Community Member, 1 Post

Hi There,

I just ran into this same error... at the same spot in the tutorial.

If you copy-and-pasted from the web tutorial, you probably picked up some extra hidden characters that php doesn't like. If you can, view the code in a text editor and display "invisibles". You'll see some extra characters, probably for carriage returns.

Go ahead and delete those.

If you aren't able to view the hidden characters, simply delete all blank lines in the code. That should also solve the problem.

I hope this helps.

Avatar
dwainwillis

23 May 2009 at 6:15am Community Member, 5 Posts

Thanks WildCat,
That's exactly what was going on. I deleted everything and re-wrote the code by hand and it worked instantly. Serves me right, for copying and pasting code! Sometimes the easy way isn't always the best. Thanks for the help!