void mysql_close(MYSQL *mysql)
Description
Closes a previously opened connection.
mysql_close()
also deallocates
the connection handle pointed to by mysql
if
the handle was allocated automatically by
mysql_init()
or
mysql_connect()
.
Return Values
None.
Errors
None.
User Comments
the mysql_close command need to stay near the connect command, which he closes or there is a warning like this: Warning: mysql_close(): 5 is not a valid MySQL-Link resource in /foo/bar on line 152
If MySQL pointer was allocated by mysql_init(), and you plan to reuse the connection descriptor, then it is important to set it to NULL after mysql_close(), otherwise the next init will think it's already allocated, then the next the call for mysql_real_connect() will SEGFAULT.
At least, that's what happened to me.
Add your own comment.