Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.9.2

Bug #1526 mysqli DSN needs socket to work
Submitted: 2004-05-28 16:00 UTC
From: jl at lusidor dot se Assigned: danielc
Status: No Feedback Package: DB
PHP Version: 5.0.0RC2 (Release Candidate 2) OS: Freebsd
Roadmaps: (Not assigned)    
Subscription  


 [2004-05-28 16:00 UTC] jl at lusidor dot se
Description: ------------ Hi I run DB 1.6.4 with mysqli driver. If I dont supply socket the connection fails. Is this normal behaviour? I need to connect with 'socket' => '/tmp/mysql.sock' in the dsn array to get it to work. It seems if you supply any value for the 6th parameter as you do in the driver it must be correct and not false/null. mysqli_connect ( [string host [, string username [, string passwd [, string dbname [, int port [, string socket]]]]]])

Comments

 [2004-05-28 16:21 UTC] danielc
Weird. It works fine for me without the socket on Windows 2000. What happens if you write a simple test script that calls mysqli_real_connect() directly? Note use of REAL connect. Provide examples of your DB and PHP scripts, please.
 [2004-05-28 16:50 UTC] jl at lusidor dot se
require('DB.php'); $conn = new mysqli("localhost", "uname", "pword", "dbase"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } printf("Host information: %s\n", $conn->host_info); $conn->close(); $conn = mysqli_connect("localhost", "uname", "pword", "dbase"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } printf("Host information: %s\n", $conn->host_info); $conn->close(); $link = mysqli_init(); mysqli_real_connect($link, 'localhost', 'my_user', 'my_password', 'world'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } printf ("Connection: %s\n.", mysqli_get_host_info($link)); mysqli_close($link); $dsn = array( 'phptype' => 'mysqli', 'username' => 'uname', 'password' => 'pword', 'hostspec' => 'localhost', 'database' => 'dbase', 'socket' => '/tmp/mysql.sock', ); $dsn2 = array( 'phptype' => 'mysqli', 'username' => 'uname', 'password' => 'pword', 'hostspec' => 'localhost', 'database' => 'dbase', ); $conn = DB::connect($dsn);works fine $conn = DB::connect($dsn2); print_r($conn); // DB_Error object Host information: Localhost via UNIX socket Host information: Localhost via UNIX socket Connection: Localhost via UNIX socket. DB_Error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => -24 [message] => DB Error: connect failed [userinfo] => [nativecode=Can't connect to local MySQL server through socket '' (2)] ** Array [backtrace] => Array ( [0] => Array ( [file] => /usr/local/lib/php/DB.php [line] => 748 [function] => PEAR_Error [class] => DB_Error [type] => -> [args] => Array ( [0] => DB Error: connect failed [1] => -24 [2] => 1 [3] => 1024 [4] => [nativecode=Can't connect to local MySQL server through socket '' (2)] ) ) [1] => Array ( [file] => /usr/local/lib/php/PEAR.php [line] => 536 [function] => DB_Error [class] => DB_Error [type] => -> [args] => Array ( [0] => -24 [1] => 1 [2] => 1024 [3] => [nativecode=Can't connect to local MySQL server through socket '' (2)] ) ) [2] => Array ( [file] => /usr/local/lib/php/DB/common.php [line] => 500 [function] => raiseError [class] => DB_mysqli [type] => -> [args] => Array ( [0] => [1] => -24 [2] => [3] => [4] => [nativecode=Can't connect to local MySQL server through socket '' (2)] [5] => DB_Error [6] => 1 ) ) [3] => Array ( [file] => /usr/local/lib/php/DB/mysqli.php [line] => 153 [function] => raiseError [class] => DB_mysqli [type] => -> [args] => Array ( [0] => -24 [1] => [2] => [3] => [4] => Can't connect to local MySQL server through socket '' (2) ) ) [4] => Array ( [file] => /usr/local/lib/php/DB.php [line] => 393 [function] => connect [class] => DB_mysqli [type] => -> [args] => Array ( [0] => Array
 [2004-05-28 16:53 UTC] jl at lusidor dot se
Do you need anymore info?
 [2004-05-28 19:16 UTC] danielc
WOAH! Too much information. First, try this script... <?php $d = array( 'phptype' => 'mysqli', 'hostspec' => 'localhost', 'username' => 'usr', 'password' => 'pw', 'database' => 'db', 'port' => '3306', // 'socket' => '/tmp/mysql.sock', ); // Direct Connection $conn = mysqli_connect( $d['hostspec'], $d['username'], $d['password'], $d['database'], $d['port'] ); if (!$conn) { echo 'direct error: ' . mysqli_connect_error() . "\n"; } else { echo "directly connected\n"; } // DB Connection $db =& DB::connect($d); if (DB::isError($db)) { echo 'db error: ' . $db->getUserInfo() . "\n"; } else { echo "db connected\n"; } ?> If that fails, get a fresh build of PHP and retry. If that fails, what version of MySQL are you using?
 [2004-06-07 01:25 UTC] danielc
Your feedback will be appreciated.
 [2004-06-25 18:39 UTC] danielc
Please read, follow the instructions in and reply to the comment from 28 May 3:16pm EDT.