0

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?

user3144056
  • 41
  • 2
  • 6

2 Answers2

1

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.

user3144056
  • 41
  • 2
  • 6
1

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

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/18542965) – Alex Romanov Jan 17 '18 at 15:00
  • Edited. Thanks and I'm sorry – user2966621 Jan 22 '18 at 15:28