Re: A Simple Problem
| From: | Chris Adams | Date: | Thu, 27 Jul 2000 01:03:39 +0000 |
| Subject: | Re: A Simple Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8451@lists.php.net to get a copy of this message | ||
> I have a small problem with using an include file. I have some code like
> this:
>
> <?
> include("login.php3");
>
> if(@mysql_connect("localhost", "root")) {
> $db = mysql_connect("localhost", "root");
> mysql_select_db("olympic",$db);
> }
> else {
> $errMsg = "There has been a problem opening the database!";
> require("../error.php");
> exit();
> }
> ?>
>
>
> The problem is that the value for $errMsg doesn't get passed to the
> 'require'd file. Is this normal? If it is not done in this way, how else
> is it possible? Using cookies?
The $errMsg value should be visible in that script. However, it looks like
that will be in the global namespace; if you are trying to access it within
a function in error.php, you'd need to add a "global $errMsg;" to the top.
What happens when you require() a file which contains only <? echo $errMsg;
?>?
Chris