Brownbay
Brownbay

Reputation: 5500

PHP include chain not working

Here's the folder structure of my project:

/ping

--/Controller
----Ping_Conntroller_Main.php
----Ping_Conntroller_Db.php

--/Model
----dbCredentials.php

--/View
----output.html.php

'ping' is the folder that contains my project and it sits inside the 'xampp/htdocs/' directory on my computer (C:/xampplite/htdocs/)

Here is the initial code for each file:

OUTPUT.HTML.PHP
---------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$root = $_SERVER['DOCUMENT_ROOT'];

include($root.'/ping/Controller/Ping_Controller_Main.php');

PING_CONTROLLER_DB.PHP
----------------------
<?php
$root = $_SERVER['DOCUMENT_ROOT'];

require($root.'/ping/Model/dbCredentials.php');

class Ping_Controller_Db
{

PING_CONTROLLER_MAIN.PHP
------------------------
<?php
$root = $_SERVER['DOCUMENT_ROOT'];

require($root.'/ping/Controller/Ping_Controller_Db.php');

class Ping_Controller_Main
{

These are the errors I get when trying to access the 'output.html.php' file in a browser:

Warning: include(C:/xampplite/htdocs/ping/Controller/Ping_Controller_Main.php) [function.include]: failed to open stream: No such file or directory in C:\xampplite\htdocs\ping\View\output.html.php on line 6

Warning: include() [function.include]: Failed opening 'C:/xampplite/htdocs/ping/Controller/Ping_Controller_Main.php' for inclusion (include_path='.;C:\xampplite\php\PEAR') in C:\xampplite\htdocs\ping\View\output.html.php on line 6

I know I must be doing something really stupid, but I've been staring at the error for the past 20mins and can't seem to get this to work.

Thanks in advance!

Upvotes: 1

Views: 885

Answers (3)

MartyIX
MartyIX

Reputation: 28648

----Ping_Conntroller_Main.php
----Ping_Conntroller_Db.php

Filenames contain double "n" (CoNNtroller).

Upvotes: 3

Topher Fangio
Topher Fangio

Reputation: 20667

Looks like your files are named "Conntroller" instead of "Controller". If this isn't the problem, you might try using backslashes instead of forward slashes to separate the directories/filenames. I'm not sure if it makes a difference for PHP on Windows, but I know it generally makes a difference on Windows.

Upvotes: 1

Jeff Mattfield
Jeff Mattfield

Reputation:

Do the two n's in the names of the actual files (as shown in your folder structure) have anything to do with it?

Upvotes: 1

Related Questions