PHP: mysqli extension doesn't load - php

I try to use MySQL with PHP and I have this error:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in 'file_name Stack trace: #0 {main} thrown in 'file_name'`
When doing print_r( get_defined_functions()), I see that the MySQLi extension isn't there, but it is "loaded" in the php.ini file (I mean this is not in a commentary).
I specify that the PHP directory is in the PATH (I'm under windows) and MySQL, PHP and Apache are on my C: disk.
I don't know where is the problem, this is probably a small thing but I can't see which one so.
My versions are:
Apache 2.4.47
PHP 7.1.7
MySQL 5.7
Windows 7
PS : php_mysqli.dll do only 97k. I don't know if it's normal.
HOW I SOLVED THIS : I have just added extension_dir="path_to_php\ext" under the lines who load extentions, in the php.ini file. This line is used to indicate where are the extentions in your hard disk. Don't forget to restart your server, it will reload the php.ini file.

First of all, run phpinfo() to make sure you are looking at the correct php.ini.
If your php.ini file has extension=php_mysqli.dll uncommented check your extension directory. You may need to set it explicitly, like:
extension_dir="C:\xampp\php\ext"
If the problem persists check the apache error log, you should find more info there.

Related

Windows PHP 5.6 built in server SQLite3

I have PHP 5.6 installed on windows 7 and I used the built in server to run websites locally for testing. I want to connect to a Sqlite3 file and I've uncommented the appropriate lines in the php.ini file in my C:\Program Files\php folder. I still get this error when trying to view the page on my local server: Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\Users\USERX\Documents\pageloadbasic.php:13 Stack trace: #0 C:\Users\USERX\Documents\pageloadbasic.php(13): PDO->__construct('sqlite:db/lhblo...') #1 {main} thrown in C:\Users\USERX\Documents\pageloadbasic.php on line 13
Why do I get this error?
A couple of notes: my phpinfo file shows:
Configuration File (php.ini) Path C:\Windows(for some reason this always defaults to C:\Windows even if there is not php.ini file in there)
Loaded Configuration File C:\Program Files\php\php.ini
But there is no php.ini file in C:\Windows. Also, my php folder does not include a php_pdo.dll in the ext folder, but I added one that I extracted from the pecl-5.0.5-Win32 archive as instructed in some other sites.
I added extension=php_pdo.dll in my php.ini file.
I uncommented extension=php_pdo_sqlite.dll.
I uncommented extension=php_sqlite3.dll.
I have these two lines in my php.ini which related to sqlite:
[sqlite]
; http://php.net/sqlite.assoc-case
;sqlite.assoc_case = 0 (I did not change anything on these two lines because I'm not sure what it is for...)
[sqlite3]
sqlite3.extension_dir = "ext" (on this line I added the "ext" directory as suggested on another post)
I have this in my php code to connect to my db file using pdo:
$db = new PDO('sqlite:db/xxxxx.db');
What am I missing? What do I need to do to get PDO to work with Sqlite3?
Problem solved. Even though I had properly uncommented all my dlls, and uncommented the sqlite3.extension_dir = "ext", you need to specifically uncomment the windows ext location on the line following ; On windows:'
extension_dir = "ext"`
And then restart your server.

Call to undefined function curl_init() in wampp

I am getting an error. I have done the following:
Find file php.ini and uncomment in wamp apache folder
Find file php.ini and uncomment in wamp php folder
checked in wamp extensions
download file and replace php_curl-5.3.13-nts-VC9-x64.zip
restart wamp.
But I still get error
Fatal error: Call to undefined function curl_init() in C:\wamp\www\wordpress\wp-content\plugins\test\curl_http_client.php on line 66
Call to undefined function curl_init
You either edit wrong php.ini file or something is missing on your system, preventing curl extension from loading. You shall check with phpinfo() where is proper php.ini, then check if you got extension entry for cURL really enabled. If so and it is still not working then next step should be checking Apache's error.log looking for detailed error messages from PHP.

phpwebsocket - Undefined Function socket_create() - Have php_sockets enabled on Windows/WAMP

I checked out the PhpWebSockets project from here:
https://code.google.com/p/phpwebsocket/
It's in its own project on my localhost (Windows 7 64-bit) box, inside of a WAMP server. I issue the following command in Windows Command Line to run the server.php file:
C:\wamp\bin\php\php5.4.12\php.exe C:\wamp\www\phpwebsocket\server.php
But it results in the following error message:
PHP Fatal error: Call to undefined function socket_create() in C:\wamp\www\phpwebsocket\server.php on line 58
My WAMP instance DOES have the php_sockets extension enabled (since I saw this similar question who had that problem).
Anyone know what I could possibly be doing wrong?
Found the answer in another thread:
Error with PHP Websocket and Wamp Server
Turns out running the file on the command line means it uses a different php.ini file than the WAMP server does. Seems stupid, but turned out php_sockets wasn't uncommented in that php.ini file, and removing it removed the error with it.

Fatal error: Call to undefined function printer_open()

I'm trying to print some string using PHP, i'm using the PHP print functions:
$printer = ("HP LaserJet Professional P1102");
$handler= printer_open($printer);
$content="Test Content";
printer_write($handler, $content);
printer_close($handler);
but I got that error :
Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\print.php on line 12
after googling it i found that i must add the php_printer.dll to the extensions file in php and add it's extension to the php.ini file, then restarting the server services, all of that accomplished but still getting that error.
p.s. I've tried it on WAMP and XAMPP
I think solution would be extension location.php_printer extension should be stored in c:\xampp\php\ext and not in c:\xampp\php. So move it to the ext-folder, and restart Apache.
Can you look into the error_log, which tells you, if it fails to load the module. You should also run a phpinfo(), which shows up all loaded modules, you must find the printer extensions there.
I hope it may resolve your issue.

"unable to load dynamic library" Errors when running PHP from command line

When I try to run my script I at first I put the shebang in the script at the top and then tried this:
php -f /home/phil/www/disable_script.php
But I'm immediately greeted by this:
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/zlib.so' - /usr/lib/php4/zlib.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Call to undefined function: date_default_timezone_set() in /home/phil/www/disable_script.php on line 3
When I just say:
php -v
I get:
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/zlib.so' - /usr/lib/php4/zlib.so: cannot open shared object file: No such file or directory in Unknown on line 0
What should my next step be? Do I need to reinstall php?
Sounds like there's a setting in your php.ini that is trying to load an extension that it can't find. Check to make sure the extension exists or edit your php.ini so it doesn't try to load the extension.
Also, date_default_timezone_set() is only available in PHP 5.1.0 or later. Your install looks to be PHP4.
PHP4 is old, ugly and not supported anymore. You should upgrade to PHP5 as soon as possible.
before that extension list (the .so's resp. dll's on Windows) the php.ini says:
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
I had luck with giving an explict path, i.e.
extension=d:\dev\fronker\php\ext\php_openssl.dll

Categories