Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2009, 10:08 AM
tvdm tvdm is offline
Registered User
 
Join Date: Apr 2009
Posts: 1
Exclamation CMS creation tuturial gives errror message

Hello all,

I want to create my own (still simple) content management system. To do this, I used the IntranetJournal.com tutorial. However, I get an error message at step 3 (http://www.intranetjournal.com/artic...09_07_04a.html). On my localhost (created with WampServer, PHP and MySQL were automatically installed using that program), I've created the neccesary files and I've completely done what the tutorial tells me to do. This is my file tree:

c:/wamp/www (localhost root) contains:
- cmsadmin (empty folder)
- images (empty folder)
- includes (folder, contains following files):
- DbConnector.php
- SystemComponent.php
- templates (empty folder)
- newArticle.php
- nieuwartikel.htm (this is the article submission form as discribed in step 3 of the tutorial)

When I tried to test creating an article via nieuwartikel.htm, I got the following errors when I click the Submit button:

HTML Code:
Warning: require_once(../includes/DbConnector.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\newArticle.php on line 3

Fatal error: require_once() [function.require]: Failed opening required '../includes/DbConnector.php' (include_path='.;C:\php5\pear') in C:\wamp\www\newArticle.php on line 3
I've already Googled it, but I haven't found an answer. To help you with diagnosing the problem, I'll provide the code of the different files.

My DbConnector.php file contains the following code:
PHP Code:
<?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['localhost'];
        
$db = $settings['interlycealedb'];
        
$user = $settings['root'];
        
$pass = $settings[''];

        
// 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);

    }


}
?>
My SystemComponent.php file contains the follwing code:
PHP Code:
<?php
class SystemComponent {

    var
$settings;

    function
getSettings() {

        
// System variables
        
$settings['siteDir'] = 'localhost/';

        
// Database variables
        
$settings['dbhost'] = 'localhost';
        
$settings['dbusername'] = 'root';
        
$settings['dbpassword'] = '';
        
$settings['dbname'] = 'mytestdb';

        return
$settings;

    }

}
?>
My newArticle.php file contains the following code:
PHP Code:
<?php
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');

// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){

// Create an instance of DbConnector
$connector = new DbConnector();

// IMPORTANT!! ADD FORM VALIDATION CODE HERE - SEE THE NEXT ARTICLE

// Create an SQL query (MySQL version)
$query = "INSERT INTO cmsarticles (title, tagline, section, thearticle) VALUES
('"
.$title."', '".$tagline."', '".$section."', '".$thearticle."')";

// Save the form data into the database
if ($result = $connector->query($insertQuery)){

// It worked, give confirmation
echo '<center><b>Article added to the database</b></center><br>';

}else{

// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database</center>');

}

}
?>
The nieuwartikel.htm file functions correctly. I really hope someone can help me!

Kind regards,
Tvdm
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 01:51 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0