Jump to content

Recommended Posts

Is it possible to use the same database connection throughout the whole application instead of creating db connection in every page?

 

I tried to pass the db connection through session variable. It appears it closes the the db connection after execution of the sql query. I ended up creating connection in every page.

 

Any suggestions?

 

Thanks!

Hi,

 

I am still new to this as well but this what I have done, I have put them into the Include . . .

 

1) new includefile.php

<?php

$hostname_con_recorenq = "localhost";

$database_con_recorenq = "test";

$username_con_recorenq = "usera";

$password_con_recorenq = "passworda";

$con_recorenq = mysql_pconnect($hostname_con_recorenq, $username_con_recorenq, $password_con_recorenq) or die(mysql_error());

?>

 

") then in my actual file, just add this command,

 

<?php require_once('includefile.php'); ?>

 

Not sure if this is the best option but it works for me, others may have other ideas beside this . . .

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.