php - PDO connection to MS SQL Server 2008 -


i have done once before in vm, however, needed create second instance of vm, , trying connect ms sql server. have php-5.3.6-nts-win32-vc9-x86 version of php installed. have correctly configured php.ini , running phpinfo() can verify have sqlsqrv pdo drivers installed correctly. using in conjunction iis 7, , have webserver , running. have following line in index.php file

$conn = new pdo("sqlsrv:server=$servername; database=classreg"); 

i have following give me feedback on if made successful connection database.

if($conn) {     echo "connection established. </br></br>"; } else {     echo "connection not established. </br>";     die(print_r(sqlsrv_errors(), true)); } 

problem is, i'm not getting out of $conn variable. i've tried echo variable, , i'm not getting feedback.

fwiw php.ini file reads these 3 lines @ end of file

[php_ms_sql_pdo] extension=php_sqlsrv_53_nts_vc9.dll extension=php_pdo_sqlsrv_53_nts_vc9.dll 

any ideas may missing?

i able fix issue doing following:

  • i created user access database in place of windows authentication.
  • i added iusr database logins group.

after doing 2 things, modified following line of code connect database.

$conn = new pdo("sqlsrv:server=$servername; database=classreg"); 

this line reads:

$conn = new pdo("sqlsrv:server=$servername; database=classreg", "<user>", "<password>"); 

one thing helped me out looking @ logs server. having issue, because wasn't getting output if statement in original code. able @ logs sql server, , able see happening. logs located @ management -> sql server logs. after made 2 changes, able connect database without troubles. hope helps else running issue this!


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -