sql server - Why can't I connect to my mssql database using PHP? -


i've done research trying php code hosted on iis connect mssql database. can't seem figure out issue. has come across before?

<?php  $servername = 'aegis-pc\sqlexpress'; $connectioninfo=array('database'=>'tttb_db');  $con = sqlsrv_connect($servername, $connectioninfo); if($con){     echo 'connection established<br />'; } else {     echo 'connection failed<br />';     die(print_r(sqlsrv_errors(), true)); }  ?> 

update, have new error:

connection failed array ( [0] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. [message] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. ) [1] => array ( [0] => 42000 [sqlstate] => 42000 [1] => 4060 [code] => 4060 [2] => [microsoft][odbc driver 11 sql server][sql server]cannot open database "tttb_db" requested login. login failed. [message] => [microsoft][odbc driver 11 sql server][sql server]cannot open database "tttb_db" requested login. login failed. ) [2] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. [message] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. ) [3] => array ( [0] => 42000 [sqlstate] => 42000 [1] => 4060 [code] => 4060 [2] => [microsoft][odbc driver 11 sql server][sql server]cannot open database "tttb_db" requested login. login failed. [message] => [microsoft][odbc driver 11 sql server][sql server]cannot open database "tttb_db" requested login. login failed. ) )

our sql server using windows authentication , our server name aegis-pc\sqlexpress user name , password blocks greyed out. can not think of reason our login failing. doing wrong?

there few things cause such problems:

1.) modules aren't loaded because vc9 instead if vc11. check compiler version system use , install correct driver.

2.) check php version , use correct driver php-version can check in phpinfo().

3.) don't forget install mssql native client otherwise can't connect database problem have every time.

your code looks , if error message sqlsrv_connect isn't found signal module not loaded.

https://www.microsoft.com/en-us/download/details.aspx?id=20098


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -