I really hope that someone can help me, because I have tried everything now in 4 days, and I am just stuck. I had a question with this before that did not get solved.
When I click one of my buttons "register" I get the following error:
Warning: include(resources/includes/header.html): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
Warning: include(): Failed opening 'resources/includes/header.html' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.2/lib/php') in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
Here is the relevant code:
header.html:
<!-- 1 button in the header -->
<li>
Register 1 <!-- Error -->
</li>
<!-- registernumbers.php is called fine. I can see my <h1> and <h2> text -->
registernumbers.php:
<?php
if( !isset( $_SESSION ) ) session_start();
?>
<?php include 'resources/includes/header.html'; ?>
<h1>Register Numbers</h1>
<h2>global/registernumbers</h2>
My folder structure is looking like this:
../../php/resources/includes/header.html
Is working, but the CSS is ofcourse not called.
resources/includes/header.html
This is the correct path, but here I get the error
<?php include(ROOT_PATH . 'resources/includes/header.html'); ?>
Does not work either
The path to the header is correct, and I even tried to uinstall MAMP.
When I use this:
When I put the header.html and registernumbers.php, where my index.php is, everything is working fine.
Does anybody have a clue on what I can do? I would really like to seperate my files in folders like this.
Updated code after response
<?php
if( !isset( $_SESSION ) ) session_start();
?>
<?php define 'APP_ROOT', '/resources/includes/header.html'; ?>
<h1>Register Numbers</h1>
<h2>global/registernumbers</h2>
<?php define ('APP_ROOT', '/resources/includes/header.html'); ?>
// Here I do not get any errors, but the header is not called either
<?php define 'APP_ROOT', '/resources/includes/header.html'; ?>
//Parse error: syntax error, unexpected ''APP_ROOT'' (T_CONSTANT_ENCAPSED_STRING) in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
Related
i have include a file sidebar.php in view of index page but it gives me a error like these
A PHP Error was encountered
Severity: Warning
Message: include(sidebar.php): failed to open stream: No such file or
directory
Filename: core/Loader.php(829) : eval()'d code
Line Number: 38
and other error is these
A PHP Error was encountered
Severity: Warning
Message: include(): Failed opening 'sidebar.php' for inclusion
(include_path='.;C:\xampp\php\PEAR')
Filename: core/Loader.php(829) : eval()'d code
Line Number: 38
the file sidebar.php is in the same directory and the code is as follows:
<div class="col-md-3 left_col">
<div class="left_col scroll-view">
<!-- sidebar menu -->
<?php include 'sidebar.php'; ?>
<!-- /sidebar menu -->
</div>
</div>
i am novice here so please forgive!
Use this instead of using raw php function (assuming your sidebar.php is in same directory where you will use this)
$this->load->view('sidebar');
They way you including file sidebar.php should be root folder where main index.php located.
Or you should use full file path C:\xampp\htdocs\.....YOUR PROJECT FILE DIRECToRY\sidebar.php
Or You can Use FCPATH APPPATH to get the filepath
Example
if your sidebar.php is in root folder <?php include FCPATH.'sidebar.php'; ?>
if it is inside application folder use <?php include APPPATH.'sidebar.php'; ?>
Load your sidebar in your controller
public function sources()
{
$this->load->view("pages/header/head", $data);
$this->load->view("pages/sidebar"
$this->load->view("admin/main");
$this->load->view("pages/footer/footer");
}
Of course adapted to your code
I've run into problem whereby I'm not able to include a header file into a PHP file
In the code below, I've removed the original content as it's quite big & anyway what the code does is irrelevant to including the header file
MAIN.PHP
<?php
php content
?>
<html>
<head>
</head>
<body >
<div>
header content
</div>
<br/>
<div>
</div>
</body>
</html>
I would like to have the following code in the header.php file & include it on all pages.
<div>
header content
</div>
When I do so with the main.php file looking as below, the page draws blank.
<?php
php content
?>
<html>
<head>
</head>
<body >
<div>
<? php include('header.php') ?>
</div>
<br/>
<div>
</div>
</body>
</html>
I've tried debugging this & following a few solutions on stackoverflow, but evidently have failed to achieve what I'm after.
Could I please request a second pair of eyes to help me spot the problem?
Well, first of all, I don't think you copied the code correctly to here.
As my debugging eyes can see, you got 2 issues:
Line 1: < is missing at the start. Change it to <?php. (Maybe
copy paste error?)
<?php include('header.php'); is missing closing tag. Change it to:
<?php include('header.php'); ?>
If you get a blank page, you probably have some errors. Try finding the "error.log" file in you working directory or add the following code at the start of the page:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
I added some php to some of my pages, but its not coming up on any of the pages.
<body class="menu">
<!-- Slide bar starts here -->
<?php require ('/Php/Slider.php');?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
in the php file I had this.
<header>
<a href="#" class="menu-toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
<nav class="menu-side">
<div class="listing">
<div class="box"><a class="list" href="/"><h1>Home</h1></a></div>
<div class="box"><a class="list" href="/DayZ_Home/"><h1>DayZ</h1></a></div>
<div class="box"><a class="list" href="/Photos/"><h1>Photos</h1></a></div>
<div class="box"><a class="list" href="/Store/"><h1>Store</h1></a></div>
</div>
</nav>
</header>
This is the exact same for all my pages, and nothing is coming up.
This is the error I get:
[02-Oct-2015 22:44:59 America/Denver] PHP Warning: include(): Failed
opening '/Php/Slider.php' for inclusion
(include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in
/home2/itskeega/public_html/index.php on line 14
Any Idea what is wrong?
Simply try this first : Remove slash in front of php in the path and run again.
If that don't work continue reading.
Let me help you as much as I can.
First thing first, this
[02-Oct-2015 22:44:59 America/Denver] PHP Warning: include(): Failed
opening'/Php/Slider.php' for inclusion
(include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in
/home2/itskeega/public_html/index.php on line 14
(just stating the obvious to me) This means,
There is a FIle called 'index.php' in public_html directory
It has a function "include()" on line 14 in its code.
The include function have a path in parenthesis following it.
There is a error in that path.
Either file "Slider.php" is not there or the script can't read it.
how do i know it for sure ?
Failed opening'/Php/Slider.php' for inclusion
Why did I tell this ?
It will help to understand errors next time.
Now let's try to solve the error, what I would do first to confirm the file permissions and every other thing is
Move the file to "public_html" folder itself.
new Path will be just Slider.php (Take note of the case).
Run your script and look for errors now.
That is the simplest way to do it.
Be very very precise in the "case" becuase I see you are not using the php conventions of naming everything.
Report back with the directory structure so we can help further.
'/Php/Slider.php' I assume you have Slider.php inside Php directory, Now the correct way to include would be:
require ('../Php/Slider.php');
Which will go back first, open the Php directory folder and look for Slider.php file.
<body class="menu">
<!-- Slide bar starts here -->
<?php require ('../Php/Slider.php');?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
EDIT:
Moving forward from the comments under this answer, you stated your directory structure as:
/public_html/index.php (home page)
/public_html/Php/Slider.php
Which means the approach I stated was fine.
To go from index.php to Slider.php the way would be:
../ (Go back)
Php/ (Open the Php directory)
Slider.php (Look for Slider.php)
Hence, require ('../Php/Slider.php');
As you mentioned that you are including this file in whole project , yet you did not mention the dirctory structure . It is always better to include files with absolute path .
try as below -
<body class="menu">
<!-- Slide bar starts here -->
<?php
$file=$_SERVER['DOCUMENT_ROOT']."<--your project dir-->".'/Php/Slider.php';
require ($file);
?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
<?php require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");?>
$_SERVER["DOCUMENT_ROOT"]. Makes your path start at /public_html/
We just launched a redesign of a client's ecommerce site running on OpenCart. We're trying to track down an error we're seeing in the Error Logs, but it's been eluding us thus far:
PHP Notice: Undefined index: route in .../vqmod/vqcache/vq2-catalog_view_theme_margaretha_template_common_header.tpl on line 360
The code on that line is:
<?php if ($this->request->get['route'] != 'common/home') { ?>
<div id="free-shipping">
<p>Free shipping on all orders!</p>
</div>
<?php } ?>
I'm not sure why this is throwing an error. Any ideas?
Change your if condition as follows:
<?php if (isset($this->request->get['route']) && $this->request->get['route'] != 'common/home') { ?>
<div id="free-shipping">
<p>Free shipping on all orders!</p>
</div>
<?php } ?>
The code may be in your theme folder's common/header.tpl or in some vqmod xml file (editing the file /vqmod/vqcache/vq2-catalog_view_theme_margaretha_template_common_header.tpl won't make any change).
Have a nice day !!
Thanks in advance for any help.
I am using a highly customised version of Twenty Eleven Wordpress Theme and basically I am trying to add a section into my header.php to appear at the top of all pages. It is to be two things.
1) If you are logged in, display the text "Welcome, USER NAME"
2) If you are logged out, display the text "Login Now >" which will then link to a lightbox or hover of somesort with the login box itself.
I am proficient with HTML/ CSS and a novice but like to experiment with PHP and I thought I had it sussed but it keeps spitting out errors, with the code below I get an error. (Code below, then error follows).
<div id="login">
<!-- Content to be shown if logged in -->
<?php if ( is_user_logged_in() ) ?>
<!-- Display Username / if logged in -->
<p class="logn-text-top">Welcome, <?php echo $current_user->user_login; ?></p>
<!-- Content to be shown if not logged in -->
<?php } else { ?>
<p class="login-text-top">Login Now<span>></span></p>
<?php } ?>
</div>
The Error I get is:
*Parse error: syntax error, unexpected '}' in /web_local/docroot/1310/cheshirefitcamps.co.uk/htdocs/wp-content/themes/cheshirefitcamps/header.php on line 107*
I've checked the code over and searched the net but as far as I can see the code is fine.
Any help would be appreciated.
Kind Regards,
Tom
You don't have an opening brace, directly after the if condition...should be as below
<?php if ( is_user_logged_in() ) { ?>