Hello,

Can anyone help me cek this filepath :

$bannerAdsPath = 'localhost/phpads/install.php';
require 'localhost/phpads/install.php';

Is it correct how I wrote it?

This error appears:

Warning: require(localhost/phpads/install.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpads\admin.php on line 6

Fatal error: require() [function.require]: Failed opening required 'localhost/phpads/install.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\phpads\admin.php on line 6

<?php require 'localhost/phpads/install.php'; ?>

this simply shows that you donot have the file in that directory, whcih you are giving path of.

check the spellings of the actual file and compare. Are you sure that the file is in the directory?

yes, I do have the file.

I wonder if I wrote the file path correctly (basically it's in localhost/phpads/install.php)

how to write it? Is it like this:

<?php require 'xampp/htdocs/phpads/install.php'; ?>

require 'localhost/phpads/install.php' is relative to your current file path so this would load C:\xampp\htdocs\phpads\localhost\phpads\install.php

You need the leading slash require '/localhost/phpads/install.php';

I think you are confusing two file system types; localhost is for the browser address bar and relates to hostnames, but the script needs the system path. If 'install.php' is in the same directory, then you can try './install.php' (./ is shorthand for this directory). You need to give the relative system path from the file that uses the require() to the required file itself, or you can give an absolute path: 'C:\xampp\htdocs\phpads\install.php'

Here is my revision:

$bannerAdsPath = '/localhost/phpads/ads.dat';
require('/localhost/phpads/ads.inc.php');

and still get this error message:

Warning: require(/localhost/phpads/ads.inc.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\phpads\admin.php on line 6

Fatal error: require() [function.require]: Failed opening required '/localhost/phpads/ads.inc.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\phpads\admin.php on line 6

the file is truely there.

hey i had the same issue and this is how i resolved it
$bannerAdsPath = '../phpads/ads.dat';
require('../phpads/ads.inc.php');

Hope its helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.