Reply to Re: how to make a database connection available to all pages?

Your name:

Reply:


Posted by Markus L. on 06/26/05 20:58

Am Sun, 26 Jun 2005 10:23:13 -0700 schrieb ndsoumah@gmail.com:

> hi all
>
> How can I make a database connection available to all the pages in my
> application?
> I tried doing it with session but it doesn't seem to work.
>
> here's what a did:
>
> start_session();
>
> if ( !$connection = @mysql_connect("localhost","root") )
> die ("Echec de la connection");
>
> // Je selectionne la base de donnees
>
> if ( !(@mysql_select_db("djoubarn_Emploi",$connection)))
> showerror();
>
> $_SESSION["connection"] = $connection;
>
>
> then on the other pages I do:
>
> start_session();
>
> $connection = $_SESSION["connection"];
>
> but this query would fail.....
>
> $uneRequete = "SELECT usagerID FROM Usager WHERE login=
> '{$loginUsername}'";
>
> if (!$resultat = @mysql_query($uneRequete,$connection))
>
> showerror();
>
> Thanks for any help.

You are not able to store a database connection resource into the session
variable. Create a new file where the database connection is ethablished
and include this file in all other application scripts.

--
-------------------------------------------------------
Try this: SCA the Smart Class Archive for PHP
http://www.project-sca.org
-------------------------------------------------------

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация