Jump to content

Recommended Posts

So this appears when I try and go on my index.php...

Warning: require_once(/TZ/v3/includes/db.php) [function.require-once]: failed to open stream: No such file or directory in /home/*REMOVED*/public_html/TZ/v3/index.php on line 5


Fatal error: require_once() [function.require]: Failed opening required '/TZ/v3/includes/db.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/*REMOVED*/public_html/TZ/v3/index.php on line 5

It's saying there's no file there but there is! 

Thanks

Edited by rizmah
Link to comment
https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/
Share on other sites

you are using an absolute path to "/TZ", but actually this directory is a part of "/home/*REMOVED*/public_html/". Use a relative or an absolute path like - "/home/*REMOVED*/public_html/TZ/v3/includes/db.php"

Edited by jazzman1

you are using an absolute path to "/TZ", but actually this directory is a part of "/home/*REMOVED*/public_html/". Use a relative or an absolute path like - "/home/*REMOVED*/public_html/TZ/v3/includes/db.php"

Thanks, that fixed it. But now when I goto the index.php it just shows a blank white screen with a bit of code in the top... ?

b96d000c9e725a9dc126418a622a25bb.png

 

Add this on top of your index.php file to check for actual errors.

ini_set('display_startup_errors',1);

ini_set('display_errors',1);

error_reporting(-1);

Nothing comes up. If I put it above the <?php in just displays that in text. If I put it below it, it's just white screen. :(

This is the top of the index.php

<?php
        $page = 'Home';
	$pageIcon = 'home';
	ob_start();
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/init.php');
	if(!($user->LoggedIn())){
		if(isset($_GET['referral'])){
			$_SESSION['referral'] = preg_replace("/[^A-Za-z0-9-]/","", $_GET['referral']);
			header('Location: register.php');
			die();
		}
		header('location: login.php');
		die();
	}
	if(!($user->notBanned($odb))){
		header('location: logout.php');
		die();
	}
	require_once('header.php');

Try the following and tell me if you get errors,

<?php
ini_set('display_startup_errors',1);

ini_set('display_errors',1);

error_reporting(-1);

session_start(); // added a session start

        $page = 'Home';
	$pageIcon = 'home';
	//ob_start();
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/init.php');
	if(!($user->LoggedIn())){
		if(isset($_GET['referral'])){
			$_SESSION['referral'] = preg_replace("/[^A-Za-z0-9-]/","", $_GET['referral']);
			header('Location: register.php');
			die();
		}
		header('location: login.php');
		die();
	}
	if(!($user->notBanned($odb))){
		header('location: logout.php');
		die();
	}
	require_once('header.php');

 

Try the following and tell me if you get errors,

<?php
ini_set('display_startup_errors',1);

ini_set('display_errors',1);

error_reporting(-1);

session_start(); // added a session start

        $page = 'Home';
	$pageIcon = 'home';
	//ob_start();
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');
	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/init.php');
	if(!($user->LoggedIn())){
		if(isset($_GET['referral'])){
			$_SESSION['referral'] = preg_replace("/[^A-Za-z0-9-]/","", $_GET['referral']);
			header('Location: register.php');
			die();
		}
		header('location: login.php');
		die();
	}
	if(!($user->notBanned($odb))){
		header('location: logout.php');
		die();
	}
	require_once('header.php');

Blank white screen still.

Blank white screen still.

 

Why do you use

	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');

Instead of

	require_once('TZ/v3/includes/db.php');

I assume your script is inside public_html. Would make your life easier...

Does your header file contain something?

Why do you use

	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');

Instead of

	require_once('TZ/v3/includes/db.php');

I assume your script is inside public_html. Would make your life easier...

Does your header file contain something?

I got an error before but now ive done that it works fine until I get the blank screen. Yes, the header does contain stuff.

 

@jazzman1 - Hmm, ill try and sign in one more time because that and register is the only thing that works :/ Edit: nope still doesnt work

Edited by rizmah

Ok. I would try the following...

 

  • Add an echo to the first line and see if it prints. If it does, you just keep moving it down the script until it stops appearing.
  • I would also use error_reporting(E_ALL); - looks a bit cleaner in my opinion
  • You can also use the developer tools on your browser to check if the server is returning a 500 error

See if one of those gives you a hint what line is failing / which error you're actually having.

Why do you use

	require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');

Instead of

	require_once('TZ/v3/includes/db.php');

I assume your script is inside public_html. Would make your life easier...

Does your header file contain something?

 

@Csharp, the relative path should be this:

require_once('./includes/db.php');

The index file is located in - /home/*REMOVED*/public_html/TZ/v3/index.php ( re-read the first posting )

Edited by jazzman1

when using a session / cookies, just delete the cookies if you have them or restart the browser page in case you're using sessions or unset them with php script.

Done it, doesn't work :(

 

 

Ok. I would try the following...

 

  • Add an echo to the first line and see if it prints. If it does, you just keep moving it down the script until it stops appearing.
  • I would also use error_reporting(E_ALL); - looks a bit cleaner in my opinion
  • You can also use the developer tools on your browser to check if the server is returning a 500 error

See if one of those gives you a hint what line is failing / which error you're actually having.

Echo appears, but i dont get what you mean with the next part

we need to know what output you're expecting to get of the script above. Also are you still using output buffering set it up with ob_start() ?

 

That wasn't the whole script there's a load more but I just showed you part of it. Just to say I am a newb to PHP coding, so I don't get most of the things you say unfortunately :/

 

That wasn't the whole script there's a load more but I just showed you part of it. Just to say I am a newb to PHP coding, so I don't get most of the things you say unfortunately :/

 

You have to show us the whole script, but speaking on this part, could you run only this part and tell me what result you get. I want to check the login session.

<?php

ini_set('display_startup_errors', 1);

ini_set('display_errors', 1);

error_reporting(-1);

session_start(); // added a session start

$page = 'Home';

$pageIcon = 'home';

require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');
require_once('/home/*REMOVED*/public_html/TZ/v3/includes/init.php');
if (!($user->LoggedIn())) {
    if (isset($_GET['referral'])) {
        $_SESSION['referral'] = preg_replace("/[^A-Za-z0-9-]/", "", $_GET['referral']);
        header('Location: register.php');
        die();
    }
    header('location: login.php');
    die();
} else {
   echo "The user is login";  
}
if (!($user->notBanned($odb))) {
    header('location: logout.php');
    die();
}
require_once('header.php');

If the user is login you should get the message - "The user is login".

Edited by jazzman1
  <br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message</b></font></td></tr></table><br />
<b>Fatal error</b>:  Call to a member function fetchColumn() on a non-object in <b>/home/*REMOVED*/public_html/TZ/v3/header.php</b> on line <b>2</b><br />
<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='Arial' size='1' color='#000000'>Free Web Hosting</font></a></div></td></tr></table>

I inspect element the white page and it said this...

The header.php is this... (only the top part of the code)

<head>        
        <title>  <?php echo $odb->query("SELECT `Tab` FROM `SiteConfig` LIMIT 1")->fetchColumn(0); ?> </title>  
        <link href='http://fonts.googleapis.com/css?family=Carter+One' rel='stylesheet' type='text/css'>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        
        <link href="css/styles.css" rel="stylesheet" type="text/css" />        
        <!--[if lt IE 10]><link rel="stylesheet" type="text/css" href="css/ie.css"/><![endif]-->
        
        <script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery/jquery-ui.min.js"></script>
        <script type="text/javascript" src="js/plugins/bootstrap/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/plugins/mcustomscrollbar/jquery.mCustomScrollbar.min.js"></script>        
        
        <script type="text/javascript" src="js/plugins/sparkline/jquery.sparkline.min.js"></script>        
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
        <script type="text/javascript" src="js/plugins/fancybox/jquery.fancybox.pack.js"></script>         

You have to show us the whole script, but speaking on this part, could you run only this part and tell me what result you get. I want to check the login session.

<?php

ini_set('display_startup_errors', 1);

ini_set('display_errors', 1);

error_reporting(-1);

session_start(); // added a session start

$page = 'Home';

$pageIcon = 'home';

require_once('/home/*REMOVED*/public_html/TZ/v3/includes/db.php');
require_once('/home/*REMOVED*/public_html/TZ/v3/includes/init.php');
if (!($user->LoggedIn())) {
    if (isset($_GET['referral'])) {
        $_SESSION['referral'] = preg_replace("/[^A-Za-z0-9-]/", "", $_GET['referral']);
        header('Location: register.php');
        die();
    }
    header('location: login.php');
    die();
} else {
   echo "The user is login";  
}
if (!($user->notBanned($odb))) {
    header('location: logout.php');
    die();
}
require_once('header.php');

If the user is login you should get the message - "The user is login".

Yeah it shows the user is login.

You need to do a "view source" in your browser to see the content of the header! If so...then everything is ok with your script until here!

 

Yeah this is basically the error

 

Fatal error: Call to a member function query() on a non-object in /home/REMOVED/public_html/TZ/v3/header.php on line 2

 we need to see your content (or a db class ) of db.php file. 

This is all the db.php...

<?php
	if(strpos(strtolower($_SERVER['SCRIPT_NAME']),strtolower(basename(__FILE__)))){
		die('Error!');
	}
	define('DB_HOST', '*REMOVED*');
	define('DB_NAME', '*REMOVED*');
	define('DB_USERNAME', '*REMOVED*');
	define('DB_PASSWORD', '*REMOVED*');
	$odb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD);
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.