Gem Posted March 11, 2009 Share Posted March 11, 2009 Hi all, Wonder if you can help I found a tutorial for building a CMS here: http://www.intranetjournal.com I'm struggling with the conenction parts. It says to build a system componant .. heres the code: <?php class SystemComponent { var $settings; function getSettings() { // System variables $settings['siteDir'] = ''; // Database variables $settings['dbhost'] = 'HOST'; $settings['dbusername'] = 'USER'; $settings['dbpassword'] = 'PASSWORD'; $settings['dbname'] = 'DB'; return $settings; } } ?> And this is the error im getting when I try to add an article: PHP Warning: main(SystemComponent.php) [function.main]: failed to open stream: No such file or directory in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\includes\DbConnector.php on line 6 PHP Fatal error: main() [function.require]: Failed opening required 'SystemComponent.php' (include_path='.;c:\php4\pear') in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\includes\DbConnector.php on line 6 I took a wild guess at the system componant being the problem ... but heres the dbconnector code as well in case its that ... <?php //////////////////////////////////////////////////////////////////////////////////////// // Class: DbConnector // Purpose: Connect to a database, MySQL version /////////////////////////////////////////////////////////////////////////////////////// require_once 'SystemComponent.php'; class DbConnector extends SystemComponent { var $theQuery; var $link; //*** Function: DbConnector, Purpose: Connect to the database *** function DbConnector(){ // Load settings from parent class $settings = SystemComponent::getSettings(); // Get the main settings from the array we just loaded $host = $settings['dbhost']; $db = $settings['dbname']; $user = $settings['dbusername']; $pass = $settings['dbpassword']; // Connect to the database $this->link = mysql_connect($host, $user, $pass); mysql_select_db($db); register_shutdown_function(array(&$this, 'close')); } //*** Function: query, Purpose: Execute a database query *** function query($query) { $this->theQuery = $query; return mysql_query($query, $this->link); } //*** Function: fetchArray, Purpose: Get array of query results *** function fetchArray($result) { return mysql_fetch_array($result); } //*** Function: close, Purpose: Close the connection *** function close() { mysql_close($this->link); } } ?> I think the problem is with the // System variables $settings['siteDir'] = ''; But it doesn't tell me what to put here ... I gueesed at http://www.bradleystokejudoclub.co.uk but it didnt like it so I took it out again .. Any help would be most appreciated Thanks Gem PS: Please excuse any typos ... I'm working with one hand at the moment as I'm recovering from an operation Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted March 11, 2009 Share Posted March 11, 2009 failed to open stream: No such file or directory in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\includes\DbConnector.php on line 6 Your include paths are wrong! Add the web directory to that array: i.e $settings['siteDir'] = '/myfile/mywebsite.com/docs/'; Whatever the path is to the document root of the website Quote Link to comment Share on other sites More sharing options...
Gem Posted March 11, 2009 Author Share Posted March 11, 2009 Hi Thanks for the reply. Can you please break that down further for me please .. I am new to all this ... The path is www.bradleystokejudoclub.co.uk > wwwroot > cmsadmin > systemcomponant.php So what do I do?? Sorry to sound stupid ... Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted March 11, 2009 Share Posted March 11, 2009 At this part of the file: $settings['siteDir'] = ''; You need to put the path to the website files between the single quotes from the root of the computer. i.e. on windows the root is c:\ linux is / Example: the path to my documents is c:\my-documents Now I dont work on windows so I dont know if you can use c:\ but im pretty sure you can use / for the root so: $settings['siteDir'] = '/webspace/wwwroot/'; I'll let you finish it off Quote Link to comment Share on other sites More sharing options...
Gem Posted March 11, 2009 Author Share Posted March 11, 2009 I am clearly an idiot ... I still dont get it! I dont understand what the path is?? Sorry xxx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.