Database host with port not handled properly

Asked by Jakub Niezgoda

Just after installation of Xibo Server when I went to http://xibo_server_location I got:
"Database connection problem. SQLSTATE[HY000] [2005] Unknown MySQL server host 'HOST:PORT' (1)"

I am using not standard port for my MySQL database host connection and I have defined that during Xibo Server installation when I was asked for DB host.

I digged down to the code and resolved my issue by correcting PDOConnect class - instead of constructing PDO object using:
  self::$conn = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';', $dbuser, $dbpass);
I changed it to:
  $hoststring = split(":", $dbhost, 2);
  self::$conn = new PDO('mysql:host=' . $hoststring[0] . ';port=' . $hoststring[1] . ';dbname=' . $dbname . ';', $dbuser, $dbpass);

Suggestion: in class PDOConnect during creation of PDO object $dbhost shall be checked if there is port included and if so it shall be used in PDO object constructor accordingly to http://php.net/manual/en/ref.pdo-mysql.connection.php.

Question information

Language:
English Edit question
Status:
Solved
For:
Xibo Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dan Garner (dangarner) said :
#1

Solved in the linked bug.