I have a small php application running on a webhost. Unfortunately my webhost insists in using '-' in db-names, which now causes problems - the php script can not connect to the database.
It works fine on their server running php 5.2, also on my old testserver with php-5.2, but not on my new test server running php 5.4. I intend to switch to 5.4 on webhost as soon as everything is tested fine on my test server.
Connecting to databases without '-' in name works fine so the hyphen has to be the issue. I have read lots about this problem, solution is always to use backticks - this works fine from cli but I just can't get it to work in php.
I have tried using backticks in $DATABASE, tried connecting directly to " `mydb-name` ", I have tried every combination of quotes, ticks, backticks - you name it, but no connection.
I also tried using PDO instead but it doesn't work either.
Code:
function anslutDB() {
// Variabler
$DB_HOST="172.16.1.10";
$DB_USER="11111_aaaa";
$DB_PASS="8blackdots";
$DATABASE='11111-mydb';
global $mysqli;
// Funktion
$mysqli = mysqli_connect($DB_HOST, $DB_USER, $DB_PASS, $DATABASE);
My testserver:
VM-guest OpenVZ running on Proxmox host.
Ubuntu 12.04, apache 2.2.24, php-5.4.13-2~precise+1, mysql-5.5.29