Home Ask Login Register

Developers Planet

Your answer is one click away!

Dave February 2016

Php Connection with Sql server not working on Production Server

enter image description here

enter image description here

I am currently working with php. I want to connect the PHP with sql server but it is not working on the production server.It worked perfectly on my local machine, as I installed the sql server driver in the extension folder of php and activated it in php-ini file.I confirmed that the driver has been loaded into the production driver as it was hosted in a windows server and not a linux server.I need assistance,because the same script with which I connected the my local machine to the cloud sql server is the same script i am using now to connect the php application to the same sql server that is now not working. Please, I need help. take a look at my connection script that works perfectly with my local machine.

  $serverName = "remote sql server IP"; //a.b.c.d
   $connectionInfo = array("Database"=>"sqlserverDBname", "UID"=>"sqlsvruserID", "PWD"=>"sqlsvrPassword");
   $conn = sqlsrv_connect($serverName, $connectionInfo);
       echo "Connection Established<br/>";
    echo "Connection could not be established<br/>";

?> Both the php application and the other application that uses sql server are on the same domain, while php-app and other-app are sub domain. Kindly help look at this. Thanks community for anticipated advice/solution


Nihar February 2016

Please add Server Name(host) instead of remote sql server IP $serverName = "remote sql server IP";

This will solve your problem i think.

Post Status

Asked in February 2016
Viewed 1,627 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life