yoda Posted March 28, 2008 Share Posted March 28, 2008 Hi All, I am in the middle of a migration project, where I have to migrate all my Linux based MySQL databases to a Windows based MS SQL 2005 Express. I have one IIS 6.0 webserver and one SQL 2005 Express server (2 boxes). I have verified that I can create an ODBC connection to the SQL server (to verify the SQL server configuration). I run into trouble as soon as I try to connect to the MS SQL server via PHP. Source code: <?php $connection = mssql_connect("TW-SQL01","test","test"); echo "connected"; ?> The last line is just to verify that my script is not stuck somewhere. Unfortunately the script is stuck which the first line. I have the mssql extension enabled (verified in phpinfo()). Any help will be appriciated. Quote Link to comment https://forums.phpfreaks.com/topic/98300-iis-6-w2k3r2-server-php-525-ms-sql-express-2005/ Share on other sites More sharing options...
billf Posted March 31, 2008 Share Posted March 31, 2008 i believe it has something to do with the permissions that are being passed. i am having a similar problem where my DNS connection looks good but then does not connect from the script. i can even run the script from the command line and it works. but at that point i am logged on as the admin so all permissions are open. i know this doesn't solve your problem, but maybe with two heads pointing in the same direction we can come up with a solution. Bill Quote Link to comment https://forums.phpfreaks.com/topic/98300-iis-6-w2k3r2-server-php-525-ms-sql-express-2005/#findComment-505556 Share on other sites More sharing options...
billf Posted March 31, 2008 Share Posted March 31, 2008 again this is not an answer to your question, but rather the work around that i used up for my situation. i could not figure out the permissions part of it (at some point i will). here is the script that i used. this was the only way i could connect to my remote server. i really hope this helps. the script basically connects and then lists out the contents (so choose a small table). -- Bill <?php $myServer = "SERVER (or 'localhost')"; $myUser = "yourUser"; $myPass = "yourPass"; $myDB = "yourDB"; //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = "SELECT * FROM yourTable"; //execute the SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); echo $num_columns . "<br>"; for ($i=0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } echo "<table>"; while (!$rs->EOF) //carry on looping through while there are records { echo "<tr>"; for ($i=0; $i < $num_columns; $i++) { echo "<td>" . $fld[$i]->value . "</td>"; } echo "</tr>"; $rs->MoveNext(); //move on to the next record } echo "</table>"; //close the connection and recordset objects freeing up resources $rs->Close(); $conn->Close(); $rs = null; $conn = null; ?> Quote Link to comment https://forums.phpfreaks.com/topic/98300-iis-6-w2k3r2-server-php-525-ms-sql-express-2005/#findComment-505673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.