RE: Trouble connecting to ms sql with ODBC on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux