All my work on php and mysql was on local server.Now i want to move to a web host.I choose one of the free hosting sites like 1freehosting.I uploaded my php pages to the file manager of the hosting site's cpanel.
I used to access the index.php
under the folder name 'core'
page on my local server like the following :
localhost/practice/core/index.php
I wrote the url with my domain name but got error .My domain name is ezphp.tk(it's also a free domain)
ezphp.tk/practice/core/index.php
But i got the following error
Warning: require_once(../classes/Cookie.php): failed to open stream: No such file or directory in /home/u377815502/public_html/practice/core/init.php on line 42
Fatal error: require_once(): Failed opening required '../classes/Cookie.php' (include_path='.:/usr/lib/php') in /home/u377815502/public_html/practice/core/init.php on line 42
My file structure in the host server is the following :
root directory as i see is the following :
file manager>practice>
inside practice i have the following folders:
-classes-core-css-includes-function-editor
my index.php is the following :
<?php
require_once '../core/init.php';
include('../includes/header.php');
if(Session::exists('home')){
echo '<p>'.Session::flash("home").'</p>';
}
if($user->isLoggedIn()){
?>
<p>Hellow <a href="../includes/profile.php?user=<?php echo escape($user->data()->username); ?>"><?php echo escape($user->data()->username); ?> </a>!</p>
<ul>
<li><a href='../includes/logout.php'>logout</a></li>
<li><a href='../includes/update.php'>update info</a></li>
<li><a href='../includes/changepassword.php'>change your password</a></li>
<li><a href="../includes/profile.php<?php echo '?user='.escape($user->data()->username);?>">profile</a></li>
</ul>
<?php
if($user->hasPermission('moderator')){
echo '<p>you ara a moderator</p>';
}
}else{
echo '<p>you need to <a href="../includes/login.php">login</a> or <a href="../includes/register.php">register</a><p>';
}
include('../includes/footer.php');
?>
Use $_SERVER['DOCUMENT_ROOT']
instead of using relative paths:
require_once $_SERVER['DOCUMENT_ROOT'].'/core/init.php';
include($_SERVER['DOCUMENT_ROOT'].'/includes/header.php');
Use this inside your other files as well, so that it's not trying to traverse odd paths.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.