Updating a mysql database using php
Instead, the My SQLi or PDO_My SQL extension should be used. In SQL safe mode, this parameter is ignored and value 'localhost:3306' is always used.
See also My SQL: choosing an API guide and related FAQ for more information. Note: Whenever you specify "localhost" or "localhost:port" as server, the My SQL client library will override this and try to connect to a local socket (named pipe on Windows).
This causes problems with mysql/networking because a new port is requested for each connection.
You can read more about the problem at:(Link too long and had to be broken up)
meaning you can use mysql_query in other functions or in no function at all and PHP will use the connection that you opened.