You can't make a database connection survive past the end of a script. So putting it in the $_SESSION is about as pointless as it gets. On Wed, July 11, 2007 3:47 am, C.R.Vegelin wrote: > I 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"); > ... > $link = mysqli_connect($mysqlhost, $mysqluser, $mysqlpsw, $mysqldb) or > die("cannot connect"); > $_SESSION['connection'] = $link; > ... > ?> > > faq.php > ----------- > <?php > require("menu.php"); > $link = $_SESSION['connection']; > $sql = "SELECT Question, Answer FROM myfaqs"; > $result = mysqli_query($link, $sql); > // previous line gives: > // Notice: Undefined variable: _SESSION in > C:\Inetpub\wwwroot\test\faq.php > // Warning: mysqli_query() expects parameter 1 to be mysqli, null > given in C:\Inetpub\wwwroot\test\faq.php > ... > ?> > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php