473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Php, Fatal error: require(): Failed opening required

103 100+
I am following the book "https://www.packtpub.com/":
https://www.packtpub.com/web-development/cms-design-using-php-and-jquery
On chapter one the give simple CMS example, but i am getting error when visit http://localhost/cms/

Warning: require(Page.php): failed to open stream: No such file or directory in C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms\ww.incs\basics.php on line 9

Fatal error: require(): Failed opening required 'Page.php' (include_path='.;C:/Bitnami/wampstack-5.4.38-0/php/PEAR;C:/Bitnami/wampstack-5.4.38-0/frameworks/smarty/libs') in C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms\ww.incs\basics.php on line 9.

The file C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms\ww.incs\basics.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. function __autoload($name) {
  4. line 9: require $name . '.php';
  5. }
  6. spl_autoload_register("__autoload");
I have added the line:
set_include_path($_SERVER['DOCUMENT_ROOT'].'/cms/ww.incs/');
Thus line 9 shifted to line 11:
Expand|Select|Wrap|Line Numbers
  1. function __autoload($name) {
  2. line 11    require $name . '.php';
  3. }
  4. spl_autoload_register("__autoload");
But the error persists:
Warning: require(Page.php): failed to open stream: No such file or directory in C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms\ww.incs\basics.php on line 11

Fatal error: require(): Failed opening required 'Page.php' (include_path='C:/Bitnami/wampstack-5.4.38-0/apache2/htdocs/cms/ww.incs/') in C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms\ww.incs\basics.php on line 11
Oct 17 '15 #1
1 2209
gintare
103 100+
Seems the reason was that i by mistake commented out the last line of the file.
C:\Bitnami\wampstack-5.4.38-0\apache2\htdocs\cms1\ww.incs\basics.php

Full file, which now works:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. function __autoload($name) {
  4.     require $name . '.php';
  5. }
  6. spl_autoload_register("__autoload");
  7.  
  8. /* added http://php.net/manual/en/function.spl-autoload-register.php */
  9. /*throughs error, because there is not such a thing as Page.php
  10.  * there is only $_SERVER['DOCUMENT_ROOT'].'/cms/folders/Page.php'
  11.  * more: http://stackoverflow.com/questions/5364233/php-fatal-error-failed-opening-required-file
  12.  */
  13. //set_include_path($_SERVER['DOCUMENT_ROOT'].'/cms1/ww.incs/');
  14.  
  15. function dbInit(){
  16.     if(isset($GLOBALS['db']))return $GLOBALS['db'];
  17.     global $DBVARS;
  18.     $db=new PDO('mysql:host='.$DBVARS['hostname'].';dbname='.$DBVARS['db_name'],$DBVARS['username'],$DBVARS['password']);
  19.     $db->query('SET NAMES utf8');
  20.     $db->num_queries=0;
  21.     $GLOBALS['db']=$db;
  22.     return $db;
  23. }
  24. function dbQuery($query){
  25.     $db=dbInit();
  26.     $q=$db->query($query);
  27.     $db->num_queries++;
  28.     return $q;
  29. }
  30. function dbRow($query) {
  31.     $q = dbQuery($query);
  32.     return $q->fetch(PDO::FETCH_ASSOC);
  33. }
  34. define('SCRIPTBASE', $_SERVER['DOCUMENT_ROOT'] . '/cms1/');
  35. echo 'SCRIPTBASE='.SCRIPTBASE;
  36. require SCRIPTBASE . 'private/config.php';
  37. if(!defined('CONFIG_FILE'))define('CONFIG_FILE',SCRIPTBASE.'private/config.php');
  38. set_include_path(SCRIPTBASE.'ww.php_classes'.PATH_SEPARATOR.get_include_path());
Oct 17 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Maximus | last post by:
I installed PEAR HTTP_Upload to my new server and now im getting this error when runnign the script. any help?
5
by: mrbog | last post by:
My server was working fine (no one else changes it but me, it's a local server on my lan), and all of a sudden I get: Fatal error: session_start(): Failed to initialize storage module: user... ...
3
by: Bhavesh1978 | last post by:
does any1 here know why i got this error message when i try to run my program in php Warning: require_once(http://localhost/own work/sql.inc.php) : failed to open stream: HTTP request failed!...
3
by: sadique | last post by:
Hello, Sadique here I've been installing a free source hotel booking system and I encountered an error while trying to go to the second step in the installation process. Fatal error:...
0
by: quitebizarre | last post by:
Having got past the 'PCC-F-NOERRFILE, unable to open error message file, facility PR2' by given 'other' read access to all the files under ${ORACLE_HOME}/precomp, I'm now stuck with this not very...
3
by: big.sexy.jcw | last post by:
Okay, I just set up my first dedicated server and everything is running fine, except one script that calls a file on another server. Failed opening required 'http://www.example.com/...
1
by: kinhoe | last post by:
i have a program in webserver. i run smooth before. but dunno why it sudden prompt out the error below? Warning: require_once() : open_basedir restriction in effect....
10
by: aakk1971 | last post by:
Fatal error: require() : Failed opening required 'define.php' (include_path='../core/include_v5:.:../core/lib/pear') in /home/aakk1971/public_html/core/kernel.php on line 37 below is the directory...
1
by: pavan52 | last post by:
0 down vote favorite hello I am new in magento. I have Uploaded The Magento Script on my domain... But when i was making changes through admin panel.. My Site Stopped Working.. and when i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.