skip to Main Content

Background: Converted from EasyApache3 -> EasyApache4 (Cpanel). Went from mpm-prefork/php5.5/dso to mpm-worker/php71fpm/fastcgi.

The error message is:

Failed to parse address "127.0.0.1:3306:3306" in /home/user/conndb/conndb.php on line 2

The code is:

<?php
$con = mysqli_connect('127.0.0.1:3306','user','password','database');
?>

I had done a previous test of this configuration on a test server with no issues – so puzzled that I ran into this in production. Tried changing to localhost but no difference. Had to revert back to EasyApache3 config.

I’m stumped. Notice the port is repeated twice in the error message. I wonder if this version of mysqli is ‘smart’ enough to know to put in 3306 itself and then chokes when it’s explicitly coded?

2

Answers


  1. Chosen as BEST ANSWER

    Closing the question.... confirmed that removing the :3306 port corrected the issue. Obviously a change php5.5 to php7.1. I'm not sure how you'd deal with a non-standard mysql port - but not an issue for me.


  2. According to PHP documentation if using non-standard port you must pass it as a fifth parameter –

    // change the last parameter to whatever your DB port is
    $con = mysqli_connect('127.0.0.1' 'username', 'password', 'database', 3306);
    

    And by “non-standard port” is meant everything, different by the result of

    echo ini_get("mysqli.default_port");
    

    because this is the default value of this parameter.

    The PHP documentation page – http://php.net/manual/en/mysqli.construct.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search