Solved

PHP 5.4 function_exists returns false for sqlsrv support

Posted on 2014-04-12
4
546 Views
Last Modified: 2014-04-12
The question is: Is there a way in PHP that I can call via a loop that shows me all the available database drivers loaded and list the driver string I would use to cause function_exists to return true?


I'm trying to create a database and configure support for it using an open source calendar program I downloaded.  The installer runs an if/else structure to see what databases are loaded in PHP for me to select from a combo box to supply it with credentials to the database (SQLExpress in my case).  I read that in version 5.4 the mssql_connect is no longer available and to DL and use the latest from Microsoft SQLSRV.exe.  I have loaded the php_sqlsrv_54_nts.dll in the extensions folder and added it into the PHP.INI file.  resetiis

PHPInfo shows sqlsrv is enabled. However, running the code below shows no love on the driver.  testing for 'odbc' and 'mysqli' return ok.  Am I missing something on the new driver here?

My php.ini has:
[ExtensionList]
extension=php_sqlsrv.dll
extension=php_sqlsrv_54_nts.dll

and I've restarted IIS8.

<?php

  if (function_exists ( 'sqlsrv' )) {
    echo "SQL is loaded" ;
  }
  else
  {
        echo "No Love from SQL" ;
        }
?>

output: No Love from SQL
0
Comment
Question by:davebird
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39996356
Try 'sqlsrv_connect' instead of just 'sqlsrv'.  SQLSRV is the name of the class but not the name of a specific function.
0
 

Author Comment

by:davebird
ID: 39996368
Thank you!  That resolved.  Any code that would loop and show me all available drivers loaded?
0
 

Author Closing Comment

by:davebird
ID: 39996377
Sorry. You answered my question.  Thank you!!
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39996399
You're welcome, glad to help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now