void mysql_close(MYSQL *mysql)


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




Download this Manual
User Comments
  Posted by Benjamin K. on June 10, 2004
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
  Posted by Erno Szabados on October 12, 2006
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.

Sign Up Login You must be logged in to post a comment.