Jump to content

Recommended Posts

 

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 :)

Link to comment
https://forums.phpfreaks.com/topic/148925-systemcomponantphp-help-please/
Share on other sites

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

 

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 ...  :(

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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