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 800219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:15:33+00:00 2026-05-14T23:15:33+00:00

I got this odd error and I can’t figure out where it came from:

  • 0

I got this odd error and I can’t figure out where it came from:

Warning: mysql_query(): 3 is not a valid MySQL-Link resource in (...)

What’s up with the 3? I don’t get it. Has anyone experienced this error themselves?

  • 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-14T23:15:34+00:00Added an answer on May 14, 2026 at 11:15 pm

    PHP uses resources as a special variable to hold links to external objects, such as files and database connections. Each resource is given an integer id. (Documentation)

    Failed Connections

    If the database connection fails you’ll likely get a "Specified variable is not a valid MySQL-Link resource" error, as Dan Breen mentioned, since the variable that is supposed to hold the resource is null.

    $link = mysql_connect('localsoth','baduser','badpass'); // failed connection
    $result = mysql_query("SELECT 1", $link); // throws error
    

    Since you’re getting a specific resource ID in the error message, the database connection likely closed unexpectedly for some reason. Your program still has a variable with a resource ID, but the external object no longer exists. This may be due to a mysql_close() call somewhere before the call to mysql_query, or an external database error that closed the connection.

    $link = mysql_connect();
    mysql_close($link);
    // $link may still contain a resource identifier, but the external object is gone
    mysql_query("SELECT 1", $link);
    

    Reusing Connections

    An issue with the mysql extension and mysql_connect() is that by default if you pass the same parameters in successive calls, it will re-use the existing connection rather than create a new one (Documentation). This can be fixed by passing true to the $new_link parameter.
    I encountered this myself on a test system where the data from two separate databases in production were combined on to one test server, and in testing the mysql_xxx() function calls walked over each other and broke the system.

    $link1 = mysql_connect('localhost','user','pass'); // resource id 1 is given
    $link2 = mysql_connect('localhost','user','pass'); // resource id 1 is given again
    mysql_close($link2); // the connection at resource id 1 is closed
    mysql_query("SELECT 1", $link1); // will fail, since the connection was closed
    

    Using $new_link:

    $link1 = mysql_connect('localhost','user','pass'); // resource id 1 is given
    $link2 = mysql_connect('localhost','user','pass', true); // resource id 2 is given
    mysql_close($link2); // the connection at resource id 2 is closed
    mysql_query("SELECT 1", $link1); // the connection at resource id 1 is still open
    

    Edit:
    As an aside, I would recommend using the MySQLi extension or PDO instead, if possible. The MySQL extension is getting pretty old, and can’t take advantage of any features past MySQL version 4.1.3. Look at http://www.php.net/manual/en/mysqli.overview.php for some details on the differences between the three interfaces.

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

Sidebar

Related Questions

I have odd problem: After starting server I got this error: undefined local variable
I got this odd behaviour I launch tests from MS Test List Editor. And
I've got this odd problem with jQuery. I'm trying to let the change of
Got this line of code here but its not working. private void Button_Click(object sender,
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
Got this error on a big $_GET query in size ~9 000 symbols (they
Got this error message while trying to configure an entitydatasource in the designer: My
I got this error today when trying to open a Visual Studio 2008 project
i'm currently using mongrel server running rails2.3.5 with ruby1.8, and got this odd behavior:
I'm experiencing an odd scenario and I'm looking for ways to figure out what's

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.