#45294 [Com]: phpcli and ms sql

From: Date: Tue, 22 Jul 2008 23:32:44 +0000
Subject: #45294 [Com]: phpcli and ms sql
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-127160@lists.php.net to get a copy of this message
ID: 45294 Comment by: kian dot mohageri at gmail dot com Reported By: lowee at lowee dot net Status: No Feedback Bug Type: PDO related Operating System: windows 2003 PHP Version: 5.2.6 New Comment: Very similar problem here with pdo_dblib. Works fine under Apache module, but not CLI. I've tried to ensure everything was built correctly. <?php $user = 'foo'; $pass = 'bar'; $dbh = new PDO('dblib:host=odyssey:2638;dbname=odyssey', $user, $pass); ?> > php testpdo.php Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] Server is unavailable or does not exist. (severity 9)' in /usr/home/kian/public_html/testpdo.php:5 Stack trace: #0 /usr/home/kian/public_html/testpdo.php(5): PDO->__construct('dblib:host=odys...', 'foo', 'bar') #1 {main} thrown in /usr/home/kian/public_html/testpdo.php on line 5 > php -v PHP 5.2.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 22 2008 16:30:13) (DEBUG) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies FreeBSD 7.0. Previous Comments: ------------------------------------------------------------------------ [2008-07-14 01:00:01] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2008-07-06 12:05:51] jani@php.net Check what php.ini file is actually loaded. Most likely you're just missing the proper extensions. Then change that script a bit: <?php define('DB_HOST','192.168.1.20'); define('DB_NAME','db1'); define('DB_USER','user'); define('DB_PASS','pass'); try { $pdo = new PDO('mssql:host='.DB_HOST.'dbname='.DB_NAME,DB_USER,DB_PASS); }catch (PDOException $e) { print $e->getMessage(); } ?> And post the output here. ------------------------------------------------------------------------ [2008-06-17 11:13:30] lowee at lowee dot net Description: ------------ php cli with pdo and ms sql it is working on any web browser but on php cli it is not working Reproduce code: --------------- define('DB_HOST','192.168.1.20'); # mtc_awdb # mtc_hds define('DB_NAME','db1'); define('DB_USER','user'); define('DB_PASS','pass'); $dbhandle = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't connect to SQL Server on"); try { $pdo = new PDO('mssql:host='.DB_HOST.';dbname='.DB_NAME,DB_USER,DB_PASS); }catch (PDOException $e) { print $e->getMessage(); } Expected result: ---------------- to show me that it is connected Actual result: -------------- 1 - SQLSTATE[01002] Unable to connect: SQL Server is unavailable or does not exist. (severity 9) 2 - SERVER not available ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45294&edit=1

« previous php.bugs (#127160) next »