Re: Connecting to SQL Server
| From: | tg-php at gryffyndevelopment dot com | Date: | Wed, 10 Aug 2005 18:20:02 +0000 |
| Subject: | Re: Connecting to SQL Server | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-40052@lists.php.net to get a copy of this message | ||
If I remember right, PHP's built-in database functions don't allow for a DSNLess
connection. Meaning you have to set up an ODBC source on the machine PHP is running on (or do a
remote ODBC connection) and connect to a DSN (a named datasource manually set up). BUT.. if you
know the address of the server and all the login information, you can do a DSNLess connection.
At my last job I used PHP on an IIS server to connect to a couple SQL Servers and an Oracle server
using ADODB for PHP.
I posted about it ages ago.. here's a link to an archived message where I posted my DSN config
file. Down here it says "Cargo System databases" you'll find examples that might
help. Sorry to be vague, but hopefully it's a start for you. Once you get it configured, it
should work fairly fluidly.
-TG
= = = Original message = = =
I have been asked by my client to use SQL Server for my php application
(uggggh!). The name of the server is "2k-server", but I am not sure
where to create the ODBC connection. Some of the docs state that all I
need is
<?php
$connection_string = 'DRIVER=SQL
Server;SERVER=2K-SERVER;DATABASE=Php_Test';
$user = 'sa';
$pass = 'MyPassword';
$connection = odbc_connect( $connection_string, $user, $pass );
?>
However that gives me an error:
Warning: SQL error: [unixODBC][Driver Manager]Data source name not
found, and no default driver specified, SQL state IM002 in SQLConnect in
/home/httpd/test/odbc/php/connect.php on line 8
Any suggestions on the best way to connect?
Todd
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.