Call To Undefined Function Sql Connect Php Windows 7

Hi, I get the following error: Call to undefined function: mysql_connect() when I try to connect to a mysql DB. I have gone through various postings and all point to the fact that PHP was compiled.

  1. Case Function Sql
  2. Cast Function Sql Server
  3. Trim Function Sql
Active3 years, 5 months ago
Call To Undefined Function Sql Connect Php Windows 7

I upgraded my PHP 5.6.30 (https://www.apachefriends.org/de/download.html) to PHP 7.0 (https://bitnami.com/stack/wamp/installer)

Everything worked fine so far and it reduces the loading time from my Page from 1,2 seconds to ~300 ms, when I use a MySQL-Database. But now I'm trying to connect to a MSSQL-Database with the following simple script, that worked fine with my old installation (PHP 5.6):

But now I got an error in my logs that says:

[Thu Dec 10 11:55:26.629956 2015] [:error] [pid 260:tid 968] [client ::1:63003] PHP Fatal error: Uncaught Error: Call to undefined function odbc_connect() in C:Bitnamiwampstack-7.0.0-0apache2htdocstestquery.php:11nStack trace:n#0 {main}n thrown in C:Bitnamiwampstack-7.0.0-0apache2htdocstestquery.php on line 11

First I thought, that my php.ini has a missing extension, so I enabled 'extension=php_pdo_odbc.dll'

the difference from the php.ini in the 5.6 version is there is the extension:'extension=php_mssql.dll' enabled. But I can't find them in the new PHP 7.0.ini

So my intension is there is no existing driver for odbc and PHP 7 yet?I found some driver for Linux here:https://aur.archlinux.org/packages/php7-odbc/

But I need something for my Windows environment.

Does anyone had the same issue and has already fixed it?

Thank und GreetingDomi

user2077480user2077480

7 Answers

Take a look in your php.ini, the string

seems to be missing in new installations, at least i had to add it manually in my new XAMPP installation (7.0.1)and accidently just activated the pdo_odbc.dll

fweberfweber

PHP7 has a few modules disabled by default that were previously enabled in PHP5.

It's an easy fix though since the extension should already exist in the ext folder that came with PHP7. You just need to modify your php.ini file to include the line:

The line above is not already present and commented out; you actually need to add it!

PHP looks for the php.ini file in C:Windows but it may also be located elsewhere on your machine. So check both C:Windows and C:php or where ever else you may have installed PHP.

After making the change you can check the results from the command line like this:

or (after restarting the web server / machine) from a .phtml file like this:

That will output a list of enabled modules which should now include odbc; if not, then you may have modified the wrong php.ini file (keep looking) or forgot to restart the web server / machine.

Tips:

If you have a non-standard installation, you can use an absolute path like this:

Tim PennerTim Penner

extension=php_mssql.dll (or extension=php_sqlsrv_56_nts.dll if you get it from Microsoft Drivers for PHP), is your problem: the Microsoft SQL driver for PHP 7 is not yet ready, the latest ETA is late January for the beta.

It looks like the cause of the delay is the intention to include SQL 2016 in that driver so you can migrate easier in the future.

UPDATE (2016/02/12):

As stated here (meet-bhagdev reply), there is an 'early technical preview' of the PHP sqlsrv driver for Windows available on github.

T30Call To Undefined Function Sql Connect Php Windows 7
6,4904 gold badges34 silver badges52 bronze badges
Adrian BAdrian B

Open your php.ini file and uncomment or add the following lines:

Reset Internet Information Services:On command prompt with admin rights type:

This fixed the problem for me.

Case Function Sql

Jhollman CutcsaJhollman Cutcsa

As an addition to Adrian B`s which mentions the official driver, you can also check https://github.com/thomsonreuters/msphpsqlThis is an unofficial port. However there are limitations for the time being.

  1. Supports only sqlsrv ODBC but not PDO
  2. Doesn`t support ZTS, only NTS
  3. Supports only x86
  4. It supports a subset of ODBC functions , you can see the list on the page.
Akin OcalAkin Ocal

I guess you was right, you need download the SQL Server ODBC driver for your PHP client platform and OS.
Here is the link for the similar issue: Call to undefined function odbc_connect()

also you can try to install this connector for MySQL (if you use MySQL): Connector/ODBC

or if you use MSSQL: ODBC Driver 11 for SQL Server

Community
Nikolay YenbakhtovNikolay Yenbakhtov

We need x86 driver from Microsoft.http://www.microsoft.com/ja-jp/download/details.aspx?id=13255*Sorry, 'ja-jp' is mine. Please select your country. There are 2 drivers, one is 32bit, but we need 64bit(x86) version.Then we could set 'ODBC data source (64bit)'. It appears on the window.Last, check your web. Maybe it works.Mar. 29th. 2016 Naio

Cast Function Sql Server

NaioNaio

Trim Function Sql

Not the answer you're looking for? Browse other questions tagged phpsql-serverwindowsodbcphp-7 or ask your own question.