Jump to content

Can't create connection with php on terminal


Lumio

Recommended Posts

Hi!

I try to do a little Consoleapp with PHP.

The problem is, when I try to connect to the local MySQL-Server, I get this errormessage:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Sites/mubix/library/database.php on line 6

That's the file where I try to connect:

<?php
require_once dirname(__FILE__).'/../settings/database.php';

global $__db__;

$dbc = mysql_connect($__db__['host'], $__db__['user'], $__db__['password'],);
if ($dbc !== false) {
	mysql_select_db($__db__['database']);
}else die("Error: Could not connect to database\n");
?>

$__db__['host'] contains localhost

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.