Re: How to pass connection as global variable ?
| From: | C.R.Vegelin | Date: | Wed, 11 Jul 2007 09:08:38 +0000 |
| Subject: | Re: How to pass connection as global variable ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258597@lists.php.net to get a copy of this message | ||
----- Original Message ----- From: "Chris" <dmagick@gmail.com>
To: "C.R.Vegelin" <cr.vegelin@hetnet.nl>
Cc: "php-general@lists.php.nt" <php-general@lists.php.net>
Sent: Wednesday, July 11, 2007 8:56 AM
Subject: Re: [PHP] How to pass connection as global variable ?
C.R.Vegelin wrote:Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line "$result = mysqli_query($link, $sql);" Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line "if (!$result) { echo "Can't execute query ($sql): " . mysqli_error($link); exit; } Any idea why ? CorI have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ---------------- <?php session_start(); require("menu.php");<snip>faq.php ----------- <?php require("menu.php");The first two lines give it away ;) You're missing a session_start(). -- Postgresql & php tutorials http://www.designmagick.com/