FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Calling a php file from another on apache server
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Calling a php file from another on apache server [message #181089 is a reply to message #181087] Thu, 11 April 2013 16:47 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <d2ddcea1-845c-4035-b46b-41c2a4b748e4(at)googlegroups(dot)com>,
Jordan Thompson <jorythompson(at)gmail(dot)com> wrote:

> index.php:
> <!DOCTYPE HTML>
> <html>
> Hello World<br>
>
> <?php
> session_start();
> include('../../cgi-bin2/hello.php');
> echo "hello " . $username . " from top<br>";
> ?>
>
> from html
> </html>
>
> hello.php:
> <?php
> require_once('db.php');
> echo "hello from ".$username." bottom<br>";
> $username="Alex";
> ?>
>
> db.php:
> <?php
> $username="user";
> $password="pass";
> $database="test";
> $host="localhost";
> echo "hello from ".$username." db.php<br>";
> ?>
>
>
> Here is the output from accessing index.php:
> Hello World
>
> Notice: Undefined variable: username in C:\xampp\cgi-bin2\hello.php on line 3
> hello from bottom
> hello Alex from top
> from html

Obviously $username is undefined at the point you use it in hello.php.
From which I'd deduce that your require_once('db.php') is wrong,
probably because the path to db.php is not properly specified.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Error while Generating SiteMap
Next Topic: Calling child class from parent class
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 04:41:59 GMT 2024

Total time taken to generate the page: 0.04212 seconds