Solved

PHP 5.4 function_exists returns false for sqlsrv support

Posted on 2014-04-12
4
562 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 83

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 83

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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