Haris Muhammad
New Member
Hi,
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 = "192.168.40.14/PERSONALEFFECTS/XMPIE"; $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.
Regards
Haris
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 = "192.168.40.14/PERSONALEFFECTS/XMPIE"; $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.
Regards
Haris