Welcome to MSSQL Forum!
MSSQL Forum - Discussions about Microsoft SQL Server

You are currently viewing our community forums as a guest user. Sign up or
Having an account grants you additional privileges, such as creating and participating in discussions.

Connection to MSSQL via PHP

Discussion in 'Installation and Administration' started by Haris Muhammad, Aug 9, 2016.

  1. Haris Muhammad

    Haris Muhammad New Member


    I have SQL server running on a windows server, however I can't connect via PHP.

    Anytime I try to connect it simply says can't find the server, I believe Im entering the servername variable incorrectly but Im struggling to think what it should actually be.

    Neither of the code snippets below return true and bothe "die"

    $serverName = "PERSONALEFFECTS\XMPIE"; //serverName\instanceName $connectionInfo = array( "Database"=>"clubline", "UID"=>"harisrethink", "PWD"=>"********"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.
    "; }else{ echo "Connection could not be established.
    "; die( print_r( sqlsrv_errors(), true)); }

    $servername = ""; $username = "harisrethink"; $password = "*******"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully";

    Any help would be greatly appreciated.



Share This Page