RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
| From: | Gerardo Rojas | Date: | Thu, 30 Oct 2003 21:03:30 +0000 |
| Subject: | RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-21941@lists.php.net to get a copy of this message | ||
you should already have that file if you have installed MS SQL server (Client Tools) on your pc. If
not, I can probably send you the file. Nothing to do with PHP, so don't recompile.
--
Gerardo S. Rojas
mailto: grojas@strategicinc.com
-----Original Message-----
From: Stoner, David M. [mailto:dmstoner@utmb.edu]
Sent: Thursday, October 30, 2003 3:01 PM
To: Gerardo Rojas
Subject: RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
OK, I'll do that. I was just looking, and it says I need ntwdblib.dll.
Maybe I already have that. I don't know if I need to recompile PHP
--with-mssql etc.
-----Original Message-----
From: Gerardo Rojas [mailto:grojas@strategicinc.com]
Sent: Thursday, October 30, 2003 2:58 PM
To: Stoner, David M.
Subject: RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
you will need to uncomment the extension for MS SQL Server in your PHP.ini
extension=php_mssql.dll
--
Gerardo S. Rojas
mailto: grojas@strategicinc.com
-----Original Message-----
From: Stoner, David M. [mailto:dmstoner@utmb.edu]
Sent: Thursday, October 30, 2003 2:55 PM
To: Gerardo Rojas
Subject: RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
OK, thanks, I'll try mssql functions next. But ODBC works too, some of the
time!
-----Original Message-----
From: Gerardo Rojas [mailto:grojas@strategicinc.com]
Sent: Thursday, October 30, 2003 2:54 PM
To: Stoner, David M.; php-windows@lists.php.net
Subject: RE: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
You don't have to use ODBC to connect. PHP supports connectivity to MS SQL
Server!
--
Gerardo S. Rojas
mailto: grojas@strategicinc.com
-----Original Message-----
From: Stoner, David M. [mailto:dmstoner@utmb.edu]
Sent: Thursday, October 30, 2003 1:53 PM
To: 'php-windows@lists.php.net'
Subject: [PHP-WIN] Trouble connecting to ms sql with ODBC on Windows
I'm new to this mailing list.
I'm using ODBC to connect to a database on a remote SQL Server from Windows
2000. I'm running PHP 4.3.3. with Apache 2, but I've also tried this with
Apache 1.3.
Here's the entire script (with dummy name, id and password):
<?php
if(function_exists("odbc_pconnect"))
{
$id =
odbc_pconnect("DataSourceName","MyId","MyPassword",SQL_CUR_USE_ODBC);
if($id)
{
echo "connected\n";
$resid = odbc_prepare($id,"select
strLastname,strFirstname,strUsername \nfrom dbo.tblPersons where
strPersonType = 'S' and strSchoolCode = 'MED' Order by
strLastname,strFirstname");
$succ = odbc_execute($resid);
if($succ)
{
odbc_result_all($resid);
odbc_close($id);
}
}
else
echo "failed to connect\n";
}
else
{
print "no such function\n";
}
?>
This works just fine when I call it from the command line. It connects and
retrieves just the data I expect.
But when I embed exactly the same script in a web page I get this:
Warning: odbc_connect(): SQL error: [Microsoft][ODBC SQL Server
Driver][Named Pipes]Specified SQL server not found., SQL state 08001 in
SQLConnect in c:\apachegroup\apache13\apache\users\dmstoner\odbctest.php on
line 13 failed to connect
What am I doing wrong???
Any help much appreciated.
-David
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php