Windows + PHP 5.3.6 - Undefined function, mysql_connect? - php

We have a brand new webserver upon which we installed Apache, then PHP, pointing it to Apache's conf dir, and installing all of the optional pieces. I'm now trying to get MySQL to connect, and it refuses. My PHP.ini lists the module as uncommented, and it is in the directory my extension dir is set to, but I just keep getting:
Fatal error: Call to undefined function mysql_connect() in C:\apache\htdocs\index.php on line 8
I installed:
PHP: VC9 x86 Thread Safe (2011-Mar-22 13:27:32)
Apache: Apache 2.2
MySQL: Windows (x86, 64-bit), MSI Installer
Windows: Windows 7
I've added PHP to my PATH var, and have phpinfo() outputting, but I'm not sure what to look for. All of the docs I've read seem to indicate that in PHP 5.3.x+ MySQL / MySQLi support should be enabled by default.
phpinfo's mysqlnd info:
mysqlnd
mysqlnd enabled
Version mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $
Compression supported
SSL supported
Command buffer size 4096
Read buffer size 32768
Read timeout 31536000
Collecting statistics Yes
Collecting memory statistics No
Tracing n/a
phpinfo's configure command info:
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--disable-isapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet" "--with-mcrypt=static"
phpinfo's loaded config file info:
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\Program Files (x86)\PHP\php.ini
Inside of that, towards the bottom:
[dba]
;dba.default_handler=
; Local Variables:
; tab-width: 4
; End:
[PHP_BZ2]
extension=php_bz2.dll
[PHP_CURL]
extension=php_curl.dll
[PHP_FILEINFO]
extension=php_fileinfo.dll
[PHP_GD2]
extension=php_gd2.dll
[PHP_GETTEXT]
extension=php_gettext.dll
[PHP_GMP]
extension=php_gmp.dll
[PHP_IMAP]
extension=php_imap.dll
[PHP_INTL]
extension=php_intl.dll
[PHP_LDAP]
extension=php_ldap.dll
[PHP_MBSTRING]
extension=php_mbstring.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
[PHP_OPENSSL]
extension=php_openssl.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
[PHP_PDO_ODBC]
extension=php_pdo_odbc.dll
[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll
[PHP_PGSQL]
extension=php_pgsql.dll
[PHP_SOAP]
extension=php_soap.dll
[PHP_SOCKETS]
extension=php_sockets.dll
[PHP_SQLITE]
extension=php_sqlite.dll
[PHP_SQLITE3]
extension=php_sqlite3.dll
[PHP_TIDY]
extension=php_tidy.dll
[PHP_XMLRPC]
extension=php_xmlrpc.dll
[PHP_EXIF]
extension=php_exif.dll
EDIT: So I played around with my .ini a bit, deleting it, putting junk in it, and phpinfo() kept the same info. So I actually looked hard, and I have my .ini set upload_max_filesize to 200M, but phpinfo says 2M. What gives? It's the exact file that phpinfo is trying to tell me is the .ini.

It turns out there was a parse error in the config file due to the paren in Program Files (x86) not being enclosed with quotes. Great call by Charles to suggest starting PHP from the command line!

Most common mistake (particularly on Windows) is to forget setting up the path of "extension_dir" in the php.ini file. PHP by default assumes C:\php\ext, whereas many prefer to unzip PHP to C:\Program Files\PHP.

Related

Composer not working on windows, gives [Composer\Exception\NoSslException] error

I'm trying to install laravel on windows 10. I installed composer to install laravel but it gives me below error.
[Composer\Exception\NoSslException] The openssl extension is
required for SSL/TLS protection but is not availab le. If you can
not enable the openssl extension, you can disable this error , at
your own risk, by setting the 'disable-tls' option to true.
Command doesn't matteri it gives above error with all commands...
I checked out this question and used solutions but it didin't work for me..
I tried these solutions
composer config -g -- disable-tls true
extension=php_openssl.dll // open openssl extension in php.ini file. - I restarted apache after that but nothing changed
I had the same issue. I did the following things to make sure the composer works out.
Find the php.ini which corresponds to where you issue the command from.
php --ini
sample output before correction:
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
This C:\WINDOWS here is a hoax. When I looked in the php installation directory, I found out there is NO php.ini. There are two files php.ini-development and php.ini-production. Just rename one to php.ini
Then you should see the correct ini path when you do php --ini
Set the extensions directory
Afterwards, open the php.ini file and uncomment the following line
;extension_dir = "ext"
should be
extension_dir = "ext"
Enable extensions
Then uncomment the extensions the same way. The following are usually required. (But please find out what you need from the messages you see from composer commands)
extension=fileinfo
extension=gd2
extension=mbstring
extension=openssl
I was running php7.2.x on my Windows 10 machine before I upgraded to PHP 7.4.10 (cli)
When I first pulled up the php.ini file, to my surprise, it was empty.
To be sure that I was looking at the right file, I did
php --ini
I was looking at the correct file.
I looked at the php folder of XAMPP and noticed two files:
php.ini-production.ini
php.ini-development.ini
I copied the contents of the first file and pasted in my php.ini file.
Then after a restart, I saw a ton of other modules were not being loaded.
I then went in to my php.ini file's Dynamic Extensions sections and had to uncomment all the following extensions:
extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
extension=pdo_firebird
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop
And then restarted Apache server agan, after saving my php.ini file.
This time, everything worked!

Install MySQLi and pgsql extensions on PHP 7.0.7

My php.ini extentions section is like as follows
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5+)
; extension folders as well as the separate PECL DLL download (PHP 5+).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite3.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
I'm using PhpStorm to host PHP.
Whenever I try to run the function i get this:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in **archive** Stack trace: #0 {main} thrown in **archive**
And my code looks like follows:
<?php
$con = mysqli_connect("localhost","root","","aula") or die(mysqli_error($con));
mysqli_query($con, 'SET NAMES utf8') or die(mysqli_error($con));
On the second line I already get the error. How can I install the extensions?
Thanks in advance.
Please make sure both extension=php_mysql.dll and extension=php_mysqli.dll are uncommented in php.in, mysqli is the "improved" MySQL library but that does not necessarily mean it replaces the mysql library entirely.
Also please make sure you set right php PATH environment variable.
change from
extension_dir = "ext"
to
extension_dir = "C:\Apache24\php\ext"
(Working on windows)
I was facing exactly the same issue.
In my case, the problem was that I had saved the php.ini file as a text file. As soon as I converted the text file to "All Files" in notepad and gave it the ".ini" extension, it became a "Configuration Settings File" and it worked.
You may check if this is the case by going through the loaded configuration file row in phpinfo(). If the value is 'none', you may be facing a similar issue.
Note: I had already uncommented the extensions and fixed the extension directory.

The mbstring extension is missing Windows AMPPS

I am running the AMPPS stack on Windows 10. I have been trying to get the configurations changed in php.ini while moving a Drupal site to my local environment. However, in the process I seem to have broken something. phppMyAdmin gives the following error:
The mbstring extension is missing. Please check your PHP
configuration.
When I check the php.ini, the extension is enabled:
extension_dir = "C:\Program Files (x86)\Ampps\php-5.3\ext"
extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
extension=php_soap.dll
;extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_tidy.dll
extension=php_xmlrpc.dll
;extension=php_xsl.dll
extension=php_com_dotnet.dll
extension=php_mongo.dll
What could be going wrong? Do I have a wrong extension directory selected?
You should check the phpinfo() for web and run php -m command for CLI if you don't see the extension in these pages then you should check the php.ini directory in the phpinfo page and alter that file.
This code in a e.g. phpinfo.php file will show you the php info page:
<?php phpinfo(); ?>

PHP unable to load dynamic library "php_pdo_oci.dll"

I'm running Apache 2.4.7 with PHP 5.5.9 on Windows 8. I installed PHPUnit and this warning image "warning" started to pop up.
Yes I enabled extension loading in php.ini as well as "extension_dir" to correct folder and there is file named "php_pdo_oci.dll" in that folder.
I tried to use different apache and php releases, but it didn't help.
Any suggestions how to fix this?
The ..._oci.dll is part of the Oracle C Interface. Unless you need to use Oracle, I suggest you go to the relevant line inside the php.ini file and uncomment the loading of this extension. However, if you need to use this extension, you’ll need to install the free Oracle Client libraries and add them to the path.
Oracle has a page where you can download the libraries needed for your setup work as expected and you can see here:
Oracle Instant Client Downloads
Note: After you choose your operational system (Windows as in your answer) in download section you will see the installation guide in foot notes of the next page. For others OSs this process will work the same way.
I currently have PHP version 7.1.9 and encountered this problem and resolved the issue. Just ensure these lines in your php.ini file are uncommented like so:
extension=php_fileinfo.dll
extension=php_ftp.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_gmp.dll
extension=php_intl.dll
extension=php_imap.dll
extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
extension=php_openssl.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=php_shmop.dll
Please restart your server application (IIS, Apache e.t.c.) after any changes to your php.ini file.
Please add below line in php.ini file
extension=pdo.so
extension=php_pdo.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
and restart apache server and check.

Missing DLL when run as script

I'm trying to get a PHP script to run every 30 minutes on my server (Win XP SP3, xampp 1.7.3).
To do so I'm running the following script (update.cmd) using the MS task scheduler
SET PATH="C:\xampp\PHP"
start php.exe \htdocs\update_dashboard.php
I am using the oci8 php extension on my webserver, but when I run that script it gives me errors that php.exe can't find the necessary dll for the oci8 extension. I get the following errors:
This application has failed to start because OCI.dll was not found. Re-installing the application may fix this problem.
PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8.dll' - The specified module count not be found.
I know that the file is there and I don't get those errors when the php is run through apache, am I running the wrong copy of php.exe? Any ideas why not? Does my PATH have to be set differently? My Windows PATH includes:
C:\instantclient_11_2;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Program Files\ActiveState Komodo Edit 5\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Altiris\Software Virtualization Agent\
Thanks for your help.
I found this problem when I switch from php 5.3 non thread safe to php 5.3 thread safe on windows 7, and I ticked install everything
I fixed the issue by commenting out extension=php_oci8.dll, extension=php_oci8_11g.dll, extension=php_pdo_oci.dll in the php.ini
I also had issues with the sybase extension wanting a libcs.dll, which I solved by removing "extension=php_sybase_ct.dll"
eg
; at bottom of php.ini -->>
[PHP_BZ2]
extension=php_bz2.dll
[PHP_CURL]
extension=php_curl.dll
[PHP_ENCHANT]
extension=php_enchant.dll
[PHP_FILEINFO]
extension=php_fileinfo.dll
[PHP_GD2]
extension=php_gd2.dll
[PHP_GETTEXT]
extension=php_gettext.dll
[PHP_GMP]
extension=php_gmp.dll
[PHP_IMAP]
extension=php_imap.dll
[PHP_INTL]
extension=php_intl.dll
[PHP_LDAP]
extension=php_ldap.dll
[PHP_MBSTRING]
extension=php_mbstring.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
;[PHP_OCI8]
;extension=php_oci8.dll
;[PHP_OCI8_11G]
;extension=php_oci8_11g.dll
[PHP_OPENSSL]
extension=php_openssl.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
;[PHP_PDO_OCI]
;extension=php_pdo_oci.dll
[PHP_PDO_ODBC]
extension=php_pdo_odbc.dll
[PHP_PDO_PGSQL]
extension=php_pdo_pgsql.dll
[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll
[PHP_PGSQL]
extension=php_pgsql.dll
[PHP_SHMOP]
extension=php_shmop.dll
[PHP_SNMP]
extension=php_snmp.dll
[PHP_SOAP]
extension=php_soap.dll
[PHP_SOCKETS]
extension=php_sockets.dll
[PHP_SQLITE]
extension=php_sqlite.dll
[PHP_SQLITE3]
extension=php_sqlite3.dll
;[PHP_SYBASE_CT]
;extension=php_sybase_ct.dll
[PHP_TIDY]
extension=php_tidy.dll
[PHP_XMLRPC]
extension=php_xmlrpc.dll
[PHP_XSL]
extension=php_xsl.dll
[PHP_EXIF]
extension=php_exif.dll
Guessing if you need sybase and oracle database connections the standard clients install oci.dll and libcs.dll in the appropriate places, for everyone else who doesn't need to use these dbs just disable the php extensions, and it should run fine :)
Ant
I've solved the problem in a way by changing the script. It's now:
C:\xampp\PHP\php.exe -f C:\xampp\htdocs\php_scripts\utils\update_dashboard.php
Thanks for the help.
Check the php.ini file that php is using by running a phpinfo() from the command line, and look to see what extensions are enabled in that file. It's quite commopn for php to be set to use a different php.ini file when running from the command line; and xampp certainly uses a different php.ini file by default. You can also tell it what php.ini file to use with the -c switch
I ran the php -m command. Turned out that my system's OCI.dll went either corrupt or missing. I recovered it by running sfc /scannow in the run box, rebooted, system reinstalled it, and it was up and running with my extensions now all working.
Am I correct that both C:\instantclient_11_2 and C:\oracle\ora92\bin contain a OCI.DLL? Because of the order of the path you might load the wrong dll. When I read Which OCI8 DLL to use in PHP 5.3 you need a different line in the php.ini depending on the version of the oracle client. I currently have no access to a pc with oracle, so I cannot verify this.

Categories