0

I am attempting to get a site using PHP to connect to my Microsoft SQL Server, below is everything I can think of:

Server: 2012
SQL Server: 2012
PHP: 7.2.6
Code:

<?php 
$serverName = "ServerName";
$connectionInfo = array( "Database"=>"DBname", "UID"=>"user.name", "PWD"=>"K5zUtwDdzyX8T1vmvtEL");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn==true ) {
    echo "Connection established.<br />";
}else{
    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));
}
?>

Other:

  • The Site and SQL Server are on different machines
  • Both boxes are Windows
  • PHP was installed manually not through IIS
  • Only error I receive is "500 Internal Server Error"
  • I have installed the drivers from Microsoft

If there is anything I have left out please let me know and I will promptly provide it. I have been lost for quite some time, I am open to any suggestions.

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
CBooze
  • 21
  • 5
  • 3
    A 500 error means that a server error occurred. To see the _actual_ error message, check your servers error log. You can also change how PHP displays errors and tell it to show all errors directly on the screen (this is not something you want in production though, since it can show sensitive data, but during development, you should). Here's how to show all errors and warnings: https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – M. Eriksson Sep 12 '18 at 22:10
  • You won't see anything but a blank page on a 500 HTTP error... PHP is probably never executed because the webserver already failed to process the request, or PHP had a fatal error.. but the logfiles should usually have something – Honk der Hase Sep 12 '18 at 23:26

1 Answers1

0

@Magnus Eriksson
Thank You, I enabled the error display using your link which then displayed the error:

Fatal error: Call to undefined function sqlsrv_connect()

Which led me to this post: Fatal error: Call to undefined function sqlsrv_connect() so adding the below to my ini file resolved that issue.

extension = php_sqlsrv_72_nts_x64.dll
CBooze
  • 21
  • 5