satbir Posted April 17, 2017 Share Posted April 17, 2017 When I am trying to include php file like <?php include_once("abc.php"); ?> then this is not working.... the contents of this file is <?php error_reporting(E_ALL); ini_set('display_errors', true); ob_start(); session_start(); $con = mysqli_connect('localhost', 'user', 'password', 'database'); if(!$con){echo "Failed to Connect Database: ".mysqli_connect_error();} $ins="insert into clicks (ip, url, date, time) values ('$ip', '$string', '$date', '$time')"; if (!mysqli_query($con, $ins)){echo "Nothing added";} mysqli_close($con); ?> database does not included ... and when i write same code in file ... then this is working well .. www.idea-ads.com Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted April 17, 2017 Share Posted April 17, 2017 You'll have to be a lot more specific than “not working”. Turn your error reporting all the way up (in the configuration, not at runtime), find out where your PHP logs the error messages (e. g. the Apache log), then come back with the exact error. A good starting point would be to check the file path. Even better, use absolute paths instead of relative ones. This is much more robust. If you want to reference a file relative to the current script, use the __DIR__ constant: require_once __DIR__.'/abc.php'; // this results in /path/to/script/directory/abc.php Your included code is also a mess, but that's another story. Quote Link to comment Share on other sites More sharing options...
satbir Posted April 17, 2017 Author Share Posted April 17, 2017 Not working Yet ... If i write code, working well, if i include file, then not working Quote Link to comment Share on other sites More sharing options...
dkub Posted April 17, 2017 Share Posted April 17, 2017 Seriously? Have you looked at the suggestions offered? Have you tried using absolute paths? What error message(s) are you receiving? "It's not working" doesn't actually provide anyone any information. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 17, 2017 Share Posted April 17, 2017 I'll try to be more straight forward and see if you understand. Is the file "abc.php" physically stored in the same folder as the script that is trying to include it? That is what you are looking at with this code. It may also be found if your path parameter in your .ini file has one setup, but I'm thinking that you probably don't have that yet. Answer this question and let's proceed from there. PS - you really should practice putting lines of code on separate lines. Makes it easier to read, easier to follow along with and easier to do maintenance on down the road. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted April 17, 2017 Share Posted April 17, 2017 satbir, you've been programming for at least four years and seem to make a living out of it. Don't you think it's time to actually start acting more like a programmer and less like a toddler? No, we don't magically solve all of your problems just by looking at a piece of code. We make suggestions based on your problem description and feedback. This means you'll have to actively work on the issue and not just sit back and relax. Got it? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 17, 2017 Share Posted April 17, 2017 If you have been doing this for at least 4 years as Jacques1 says, then something is seriously wrong. How can an experienced coder even think of embarrassing himself with a question such as yours? Are you pulling the forum's collective leg? Or just bored and looking for conversation? Quote Link to comment 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.