This blog is NOFOLLOW Free!

The magic space of the IT find what you seek or get lost


Php mysql connect ignores port for localhost

I just tried to connect with php to an other mysql server which runs on my localhost on an other port then the standard 3306. I used this syntax:

mysql_connect('localhost:3307', 'mysql_user', 'mysql_password');

But the damn php always connected to the default mysql server with port 3306.
After a lot of google searching I found the solution.

If you are using localhost as your mysql server, php always use the port 3306. It simply ignores this value.
Easy workaround, is that you use with the new port.

mysql_connect('', 'mysql_user', 'mysql_password');

Btw: If sql safemode is turned on the server paramter is ignored. Ask your hoster to change it, or to turn it off.

Fatal error: Call to undefined function the_flattr_permalink() in /srv/www/webs/aschneider/magicspace_eu/htdocs/wp-content/themes/lightword-custom/single.php on line 23 Call Stack: 0.0002 235640 1. {main}() /srv/www/webs/aschneider/magicspace_eu/htdocs/index.php:0 0.0003 238600 2. require('/srv/www/webs/aschneider/magicspace_eu/htdocs/wp-blog-header.php') /srv/www/webs/aschneider/magicspace_eu/htdocs/index.php:17 0.4261 54903152 3. require_once('/srv/www/webs/aschneider/magicspace_eu/htdocs/wp-includes/template-loader.php') /srv/www/webs/aschneider/magicspace_eu/htdocs/wp-blog-header.php:19 0.4332 55330768 4. include('/srv/www/webs/aschneider/magicspace_eu/htdocs/wp-content/themes/lightword-custom/single.php') /srv/www/webs/aschneider/magicspace_eu/htdocs/wp-includes/template-loader.php:74