Solved

PHP 5.4 function_exists returns false for sqlsrv support

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Grouping 2 41
echo paypal data on screen 5 50
Really simple no curl. Send a post 3 times 4 25
I've got an interview this morning and I want to sound intelligent... 4 52
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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