Windows PHP 5.6 built in server SQLite3 - php

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.

Related

PHP Thread class not founded with PHP7

I am trying to enable Thread with PHP script. I have followed the following steps for enabling PHP thread.
Step 1:- Download and unzip pthread lib from here
Step 2:- Copy php_pthreads.dll and paste into the php\php7.2.14\ext and php\php7.2.14\ folder.
Step 3:- and pthreadVC2.dll and paste into the apache\apache2.4.37\bin
Step 4:- Enable thread in php.ini which is located in apache\apache2.4.37\bin and after updating its look like something below.
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_extension=On
extension=php_pthreads.dll
Step 5:- Enable thread in php.ini in which located at \php\php7.2.14
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_dl = On
extension=php_pthreads.dll
Step 6:- I have restarted wampp server with all services.
Still, I am getting the error as
Fatal error: Class 'Thread' not found in {PHP file with location with line number}.
Update
I have changed DLL files and restarted a server as we discussed and redirect to a new error as below.
[24-Jan-2019 10:29:20 UTC] PHP Fatal error: The apache2handler SAPI is not supported by pthreads in Unknown on line 0
[24-Jan-2019 10:29:20 UTC] PHP Fatal error: Unable to start pthreads module in Unknown on line 0

PHP: mysqli extension doesn't load

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.

sqlsrv driver for Windows PHP PDO SQL server

I've added and enabled in php.ini given .dll, got Microsoft SQL Server 2012 Native Client, previously configured it successfully on 2 other machines, but on my local one It just says could not find driver have I missed something?
php.ini: extension=php_pdo_sqlsrv_54_ts.dll
script: new PDO("sqlsrv:Server={$_dbConfig['server']};Database={$_dbConfig['dbName']}", $_dbConfig['username'], $_dbConfig['password'])
In php error log I get strange: [08-Nov-2014 18:18:31 UTC] PHP Warning: PHP Startup: in Unknown on line 0 but have no idea why, php.ini itself is configured as my other working machines.
I had to change in php.ini:
extension_dir = "ext" to extension_dir = "C:\PHP\ext"
Got it from here: https://serverfault.com/a/240012/193005

Enabling the cURL library for PHP using XAMPP for Windows

I am running PHP code with the following code invovled:
$ch = curl_init();
When I get to this line, the following error is returned:
Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\myfiles\API\IPVIKING_API.php on line 79
Now I've found all the answers talking about enabling the curl extension in the php.ini file, and I've done that, following this question here: How to enable curl in xampp?.
My problem is I do not have these 3 files:
C:\Program Files\xampp\apache\bin\php.ini
C:\Program Files\xampp\php\php.ini
C:\Program Files\xampp\php\php4\php.ini
I instead have 2 files called
C:\Program Files\xampp\php\php.ini-development
C:\Program Files\xampp\php\php.ini-production
I've uncommented the
;extension=php_curl.dll
line in both of them, restarted both my browser and xampp, yet it still gives me the same error. Suggestions?
Make an
<?php phpinfo(); ?>
there you can see which php.ini is loaded. In this file you uncomment the the extension line.
When there is no php.ini in this path which is in the phpinfo this should be xampp/php/php.ini then rename one of the two files
C:\Program Files\xampp\php\php.ini-development
to
C:\Program Files\xampp\php\php.ini
You should move C:\Program Files\xampp\php\php.ini-production to C:\Program Files\xampp\php\php.ini.
rename "C:\Program Files\xampp\php\php.ini-production" "C:\Program Files\xampp\php\php.ini"
And then change:
;extension=php_curl.dll
to
extension=php_curl.dll
Then restart Apache.
Some systems require two files to be copied from where PHP is installed to your WINDOWS\System32 directory:
libeay32.dll
ssleay32.dll
Update:
copy "C:\Program Files\xampp\php\php.ini" "C:\xampp\php\php.ini"
search for 'php.ini' file in
xampp\php\ directory
open php.ini
find for 'curl'
you will get line
;extension=php_curl.dll
uncomment it by removing semicolon at front of the line
extension=php_curl.dll
There is a file named php (I think this is the real php.ini) with the type as configuration settings that is the one you need to uncomment extension = php_curl.dll. You should also uncomment the .ini-development and .ini-production. Restart and both browser and apache and it should work.

Include_path in php.ini

I'm trying to send mail using PEAR framework (and WAMP).
I installed PEAR and package MAIL and it is in correct folder. Problem is with include_path in php.ini.
When I checked where is my php.ini (php --ini), I have result:
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\wamp\bin\php\php5.3.13\php.ini
Scan for additional .ini files in:
Additional .ini files parsed:
In C:\wamp\bin\php\php5.3.13\php.ini I set:
include_path = ".;C:\wamp\bin\php\php5.3.13\pear"
And I restarded WAMP.
After click button to send mail, I have following error:
Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\send_mail.php on line 2
Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\send_mail.php on line 2
Fatal error: Class 'Mail' not found in C:\wamp\www\send_mail.php on line 45
No idea, why include_path is here '.;C:\php\pear'.
Mike B told me to look at your phpinfo() to know exactly what ini file(s) are being used. The file was differ between cli and apache calls (php --ini is misleading).

Categories