I got "Warning: mysql_query(): 10 is not a valid MySQL-Link resource"
referring to a line in my PHP script where I executed a query using "mysql_query($query, $link_identifier)"
views:
102answers:
4Then the value of $link_identifier
seems to be 10
and shouldn't be:-)
$link_identifier
would have to be a value you got from mysql_connect
. You don't really need to include it if you are only using one database; every mysql_
function uses the last database you mysql_connect
ed to by default.
If you're not trying to pass a link identifier, then chances are that you're trying to use mysql_query
in a way it's not intended. I'll need to see the code that calls it in order to say more.
10's a bit high for a MySQL link identifier, unless you're holding 10 open connections to MySQL in your script, or close/reconnect for each query. Are you trying to pass a previous query result instead of the DB handle? Something like this:
$dbh = mysql_connect(...);
$stmt = mysql_query('SELECT ...', $dbh);
and later on after a series of queries, maybe doing
$stmt = mysql_query('SELECT ...', $stmt); // <--using $stmt instead of $dbh
As well, though not likely, mixing mysqli and mysql handles isn't supported. They both do the same stuff and use the same libraries internally, but maintain seperate connection pools which can't be shared.
The resource was closed prior to the execution of the query. Read comment of 'ircmaxwell' on one of the answers to this question. Thanks 'ircmaxwell'.