March 30, 2009 at 1:46 pm
:unsure:
I am running an Apache Server 2.2 on a Windows XP machine.
I have PHP 5 running and need now to connect to an MSSQL 2005 database.
It is simple with MYSQL, but I am struggling to find a simple set of instructions as to how
to achieve this.
I have tried a couple, but none succeeded.
At present the Apache Server is running as localhost, although once I have figured this out,
eventually it will be remote Access.
What I am really after is a set of step by step instructions.
Andrew
March 30, 2009 at 3:46 pm
Further to my last posting I have found out some info and had a go at it.
First issue is the location of php.ini
On my system, PHP and Apache are installed under C:\xampp
The location of this seems to be varied depending upon what you read.
I am assuming it is the one in C:\xampp\php
But others say it is in C:\xampp\apache\bin
or c:\windows
I am trying to add the line
extension=php_sqlsrv.dll to enable connection to mssql server
I have done this in the file php.ini in C:\xampp\php
The file was placed in c:\xampp\php\ext folder
I stopped and started the Apache Server, but when I try to connect with php using
$serverName = "(local)";
$connectionInfo = array( "Database"=>"Training");
$conn = sqlsrv_connect( $serverName, $connectionInfo);[/b]
I get the error message
Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\ConnectTraining.php on line
If I try to specify SQL Server Name and SQL Login Details with
$serverName = "svr-sql";
$connectionOptions = array("Database"=>"Training","UID"=>"MYUID","PWD"=>"MYPWD");
$conn = sqlsrv_connect( $serverName, $connectionOptions);
I get the same error message
This implies that the sqlsrv_connect function call is either not defined correctly
or
It is not being referenced via the php.ini extensions function.
Not sure how to check which it is or what I am doing wrong.
Any ideas or help much appreciated.
Andrew
March 30, 2009 at 5:54 pm
I checked the Apache error log and it said that the sqlsrv.dll could not be loaded
[font="Comic Sans MS"]PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\xampp\\php\\ext\\php_sqlsrv.dll' - The specified module could not be found.\r in Unknown on line 0[/font]
As far as I can see, all the parameters in the ini file are set up ok,
so I am to the point where I really need some help with this, because I now have NO idea.
April 2, 2009 at 3:28 pm
Thanks for all the help! :Whistling: that'll be me then.
I have actually resolved the problem.
I used the thread safe version php_sqlsrv-ts.dll instead.
PHP was running thread safe by loading its own core php5ts.dll with Apache 2.2,
and the MS version had to be compatible I think.
Whatever, it fixed the problem, and it is now working perfectly ok.
If you need a job doing ........
April 7, 2009 at 10:38 am
i still dont understand how u do it...
i've already done everything you said before...
did you needed to install anything else? IIS or something?
i get from this code:
$serverName = "(local)";
$uid = "sa";
$pwd = "xxxxx";
//$pwd = file_get_contents("C:\AppData\pwd.txt");
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>"ABC");
print_r($connectionInfo);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
echo "Unable to connect. ";
die( print_r( sqlsrv_errors(), true));
}
this error:
Array ( [UID] => sa [PWD] => xxxxx [Database] => ABC ) Unable to connect.Array ( [0] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0
=> 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )
help please!...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply