rizmah Posted September 14, 2014 Share Posted September 14, 2014 (edited) 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 September 14, 2014 by rizmah Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/ Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 (edited) 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 September 14, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491042 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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... ? Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491043 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 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); Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491044 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491045 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 A chance to see some part of this problematic script? Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491046 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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'); Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491047 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 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'); Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491048 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491049 Share on other sites More sharing options...
Csharp Posted September 14, 2014 Share Posted September 14, 2014 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? Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491050 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 Then, maybe you die() somehow. What result are you expecting to get here? Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491052 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 (edited) 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 September 14, 2014 by rizmah Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491053 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491054 Share on other sites More sharing options...
Csharp Posted September 14, 2014 Share Posted September 14, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491055 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 (edited) 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 September 14, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491056 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491057 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 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() ? Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491059 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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 :/ Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491060 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 (edited) 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 September 14, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491061 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 <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> Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491062 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491063 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 (edited) 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! Edited September 14, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491064 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491065 Share on other sites More sharing options...
jazzman1 Posted September 14, 2014 Share Posted September 14, 2014 (edited) we need to see your content (or a db class ) of db.php file. Edited September 14, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491066 Share on other sites More sharing options...
rizmah Posted September 14, 2014 Author Share Posted September 14, 2014 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/291057-what-am-i-doing-wrong/#findComment-1491068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.