I found this strange error and I did not know where it came from:
< Code> Warning: mysql_query (): 3 does not have a valid MySQL-link resource (...)
What's going on with 3? I do not get it. Has anyone experienced this error on its own?
Such files and database connections are assigned an integer ID ()
Failed connection
If the database connection fails, then you probably get the "Not specified valid MySQL-link processing resource" error, because Dan Beryun mentioned that the variable that the resource has to capture is zero.
$ link = mysql_connect ('Lokhoth', 'Badusar', 'Badpass'); // failed connection $ result = mysql_query ("SELECT 1", $ link); // Error Error
Since you are receiving a specific resource ID in the error message, for some reason the database connection has stopped unexpectedly, still in your program a resource ID There is a variable with, but the external object no longer exists. It may be it to call mysql_query
before calling
$ link = mysql_connect (); Mysql_close ($ link); // $ link can still contain a resource identifier, but external object mysql_query ("SELECT 1", $ link) has gone;
Usage of renections
An issue with mysql extension and mysql_connect ()
is that by default if you Instead of making a new (), the same parameter will be used in the same call, it will reuse the existing connection, it can be determined by going through the true
parameter to the $ new_link
parameter .
I encountered it on a test system where the data was collected from two different databases in production, for a test server and mysql_xxx ()
Went to the other and broke the system.
$ link1 = mysql_connect ('localhost', 'user', 'pass'); // Resource ID 1 $ link2 = mysql_connect ('localhost', 'user', 'pass'); // Resource ID 1 is given again mysql_close ($ link2); // Connection mysql_query ("SELECT 1", $ link1) to Resource ID 1 is closed; // Close
after closing $ new_link
:
$ link1 = mysql_connect ('localhost') User ',' pass'); // Resource ID 1 $ link2 = mysql_connect ('localhost', 'user', 'pass', true); // has given resource ID2 mysql_close ($ link2); // Connection on Resource ID2 is closed mysql_query ("SELECT 1", $ link1); // Connection on Resource ID 1 is still open
Edit:
On the one hand, I can advise to use the extension or if possible MySQL The extension is getting too old, and MySQL can not take advantage of any previous feature of version 4.1.3. See some details on the difference between the three interfaces.
Comments
Post a Comment