[nycphp-talk] Re: mysql_close() error
Faber Fedor
faber at linuxnj.com
Tue Dec 21 17:00:57 EST 2004
On 21/12/04 16:20 -0500, Frank Wong wrote:
> Has anyone seen an error like this before?
>
> Warning: mysql_close(): 12 is not a valid MySQL-Link resource
>
> I connected to the DB using
> *************************************************************************
> // Connecting, selecting database //
> $link = mysql_connect($host, $sys_user, $sys_password)
> or die("Could not connect : " . mysql_error());
> mysql_select_db($sys_db) or die("Could not select database");
> *************************************************************************
>
> I tried to close using
> *************************************************************************
> // Closing connection //
> mysql_close($link);
> *************************************************************************
>
> Other than that, I only use the $link to query the DB. How does $link
> become 12 as stated in the error message? This is driving me nuts...
The way I read this is as follows:
You open a connection to MySQL and assign that connection to $link.
$link is kinda like a filehandle; it's a number that magically points to
something. If you were to execute the mysql_connect() multiple times and
print $link after each, you'll see increasing (probably sequential)
numbers.
For some reason, when you go to close $link, it's no longer pointing to
a database connection/filehandle.
So don't worry about the value of $link, worry about why $link no longer
points to a database resource.
--
Regards,
Faber
Linux New Jersey: Open Source Solutions for New Jersey
http://www.linuxnj.com
More information about the talk
mailing list