PHP/Local SQL Server Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
teedogg54
Forum Newbie
Posts: 1
Joined: Fri Apr 02, 2010 2:51 pm

PHP/Local SQL Server Database

Post by teedogg54 »

I am currently creating a website in which I need to be able to access a database on my company's network. I have already established that I can access certain files on the network through the website as long as I am on a network computer, but I can't seem to figure out how to connect to our SQL Server database at the moment. I can connect to the database through SQL Server, but I can't seem to figure out the exact connection string. When accessing other files, I use 'http://server/' and the filename. According to SQL Server, the server name is SERVER. Is there anything specific I need to do to connect to this with php? This is my current code for attempting this connection:

function getProdSched2(){
$q = 'SELECT * FROM [databaseName].[dbo].[tableName]';
$link = mssql_connect('SERVER', 'user', 'databaseName');
if (!$link || !mssql_select_db('databaseName', $link)) {
die('Unable to connect or select database!');
}
$result = mssql_query($q, $link);
return $result;

}
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP/Local SQL Server Database

Post by Christopher »

Check the PHP manual, especially the comments. I think you need the server name to contain "\\SERVER_NAME\DATABASE_NAME".
(#10850)
Post Reply