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

  • SEARCH
  • Home
  • 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 6088765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:01:24+00:00 2026-05-23T12:01:24+00:00

Can the same mysql resource be used for multiple queries? $queries=array($q1, $q2); $link=mysql_connect(…); mysql_select_db(…);

  • 0

Can the same mysql resource be used for multiple queries?

 $queries=array($q1, $q2);
 $link=mysql_connect(...);
 mysql_select_db(...);

 for($i = 0; $i < count($queries); $i++) {

      echo "Link is of type " . gettype($link) . "<br />";

      if(is_resource($link)) {
           mysql_query($queries[$i], $link);
      } else {
           echo "Did not execute query. <br/>";
      }
 }

 disconnect($link);

Output:

link is of type resource
Successfully executed query
link is of type resource
Did not execute query.

EDIT: I wanted to point out from the output that the first query executes but the second does not. In between, there is no change to the link. How the queries execute kinda doesn’t matter, either (IMHO).

EDIT 2: My exact code below:

$link = mysql_connect("localhost", ........);
mysql_select_db(....);

for ($row = 0; $row < $numRows; $row++) {
    if (($query = buildQuery($mainArr, $rowArr, $row)) === null) {
        echo "Error - could not build query. <br />";
        return;
    }

    echo "Link is of type " . gettype($link) . "<br />"; 

    if (is_resource($link)) {
        if ((mysql_query($query, $link))) {
            if($debug) {
                echo "Successfully executed query <br />";
            }
        } else {
            if ($debug) {
                echo "This comes up when row is " . $row . "<br />";
                echo "Link is of type " . gettype($link) . "<br />";
                echo "Datawrite failed - " . $query . "<br />";
                echo "the official line is " . mysql_error($link) . "<br />";
            }
        }
    } else {
        echo "Did not execute query <br />";
    }
}

disconnect($link);
  • 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-23T12:01:25+00:00Added an answer on May 23, 2026 at 12:01 pm

    Each iteration of the for loop contains a call to buildQuery() (not shown here). Does it affect $link in some way, or change the value of $debug?

    Additionally, your loop references $numRows, which is not defined here. How many times does the loop execute?

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

Sidebar

Related Questions

Where multiple people can work on same css. is it possible to follow semantic
Can I write the same queries (select, insert, update etc.) in LINQ to Entites
I use this code to update data in database table. Can reuse same code
Why do we need the html5 canvas element, when the same can be achieved
Bellow is the code for the simplest GUI countdown. Can the same be done
Can we have same delegate for two events ? which have same number of
While for the most part you can generate the same MSIL, there are definitely
Are there WinAPI functions that do the same what can do standard Windows utility
It appears m2eclipse is not recognizing my $M2_OPTS variable. I can run the same
Can the application use set same char in the XON and XOFF? If yes,

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.