|
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
-------------------------------------------------------
Navigation:
[Reply to this message]
|