Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:55:17+00:00 2026-05-26T17:55:17+00:00

When working on a file, I open and close connections like this: require(../StoredProcedure/connect.php);//users.user_id //..some

  • 0

When working on a file, I open and close connections like this:

require("../StoredProcedure/connect.php");//users.user_id 

 //..some query and code

mysql_close();

I do that multiple times for the whole file.. is it more efficient, to open the connection once instead and close it at the end of the file instead..

I also get the error message:

 No database selected

But I do require the connect file with teh database selected..why do I get that message?

That is what is inside the file:

<?
    $conn=mysql_connect("localhost","root","") or die(mysql_error);
    mysql_select_db("politicalforum",$conn); 
?>

The connection works..I tried with other queries

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:55:18+00:00Added an answer on May 26, 2026 at 5:55 pm

    If you are having multiple connections to a database in one program/instance and everytime you call

    require('../StoredProcedure/connect.php');
    

    The best policy for a database connection in a script is to call it the first time you need it and close it the last time you will use it. Basically at the top and bottom of the script.

    On a side note:

    include('../StoredProcedure/connect.php');
    

    is faster than require and if you can use single quotes around everything. Your script will execute faster with less strain on your server resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a program which reads some data from a file formatted like
On whatever reason this is not working (says 'file not found'), set in=c:\myprogram\_save cd
Does anyone see a problem with this, its not working saying bad file descriptor
The file format I'm working with (OFX) is XML-like and contains a bunch of
Here's the XML file i'm working on: <list> <activity>swimming</activity> <activity>running</activity> <activity>soccer</activity> </list> The index.php,
I now have a working JSON formatted file from my PHP scripts. The next
Am working on file / folder event capturing of OS X 10.5 and 10.6
I working on adding file uploading to my web application. I'm using an iframe
I'm working on a file sharing website, I need a way to take screenshots
I'm working on a file format that should be written and read in several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.