Jump to content

php include_once("filename.php"); not working


satbir

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.