I'am trying to run Symfony 3.x with :
Ubuntu 16.04
PHP 7.0
NGinx
I would like to interact with my PGSQL database that I created but I get this error :
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/20151012/php_pdo_pgsql.dll' -
/usr/lib/php/20151012/php_pdo_pgsql.dll: cannot open shared object
file: No such file or directory in Unknown on line 0
[Doctrine\DBAL\Exception\DriverException] An
exception occured in driver: could not find driver
[Doctrine\DBAL\Driver\PDOException] could not find driver
[PDOException] could not find driver
So I looked at my phpinfo() and it seems that pgsql driver is enabled
Can anyone help me on this one ?
You must properly install the PostgreSQL module and enable it. http://php.net/manual/en/pgsql.installation.php
P.S. do not use '.dll' files on the servers with UNIX based OS, because these extensions are compiled for the Windows operating system (for UNIX based OS you must use '.so' files).
I had a very similar issue:
I fixed it by applying the same patch as for this subject:
pdo_parse_params error in pdo_odbc.so whenever PHP starts in Fedora 20
In a nutshell: if a module has already been loaded by the /etc/php/7.2/mods-available/<module>.ini (or equivalent path for your OS), then the module should not be uncommented (= made active) in the php.ini files. (two of them, cli and server).
You may ensure this, by checking phpinfo(), and observe how pdo_pgsql is still active in there, despite the line being commented in php.ini!
For me, none of the above solutions worked. Uncommenting extension=pgsql in php.ini also didn't work in and of itself.
It seemed as if postgresql wasn't installed even though I had installed it on my Ubuntu using
sudo apt-get install postgresql-12
Finally, I realized I had to install:
sudo apt-get install php-pgsql
I had a similar problem and (after installing the PHP pg driver) I had to add two files to /etc/php.d
20-pgsql.ini
extension=pgsql.so
30-pdo-pgsql.ini
extension=pdo_pgsql.so
Putting these extension config lines in the php.ini kept giving me the pdo_parse_params error
The only solution that seemed to work for me was to comment out extension=pdo_pgsql and extension=pgsql inside /etc/php8.1/cli/php.ini by adding ; in front of the them:
;extension=pdo_pgsql
;extension=pgsql
This is for PHP version 8.1
Related
pdo is working fine with mysql but with pgsql its giving error 'PDOException' with message 'could not find driver' I've installed php5-pgsql package which also includes pdo_pgsql
http://packages.debian.org/sid/php5-pgsql
This package provides a module for PostgreSQL database connections directly from PHP scripts. It also includes the pdo_pgsql module for use with the PHP Data Object extension.
my dsn is pgsql:dbname=DB;host=192.168.0.2
I am using Ubuntu 10.04
This message means you need to install and or activate postgresql extension in PHP
This solution works for me :
To install postgresql extension
[sudo] apt-get install php-pgsql
after, for activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file
Finally, type :
[sudo] /etc/init.d/apache2 restart
To restart apache server if you use apache such as was my case...
1) Have you enabled pgsql.so in php.ini (extension=pgsql.so)?
2) Is you Postgresql listenin on 192.168.0.2 interface? (You can check it by netstat -tpln)
3) How you authenticate your access into Postgresql?
Make sure you've uncommented the line that tells php where the Postgres driver is (usually extension=pgsql.so) in the main php.ini file.
I had the same issue. First of all - check is it enabled in php.ini. Uncomment extension=php_pdo_pgsql...
than set up extension directory!!
extension_dir = "ext" ; for your case it could be other dir.
and do not forget to restart server after changing the config.
Try to remove semicolon in front of
extension=pgsql
extension=pgsql.so
included in your php.ini file
You can do that from the XAMPP Control Panel.
Here is what I did to solve the problem.
Edit php.ini and remove ; from extension=pdo_pgsql. Also, add extension=pgsql.so to the php.ini file.
Make sure to restart the Apache server before you try to see the result.
I had the same problem with another solution. I lost my around 4 hours to solve this problem. Please check the following to solve this problem.
Check php.ini file and remove semicolon from this line
extension=pgsql
extension=pdo_pgsql
Restart your apache2 server
sudo service apache2 restart
Check if your PDO driver has updated in localhost phpinfo()
I did All the things right and still I had this problem. And you know why? Because I had several versions of php installed. So I was running php7.4 in my php cli but localhost was running on php7.2. So always check your php versions.
Check your php version on localhost and terminal cli
When you do not have postgresql installed on the same machine that is Apache and PHP; you have to install php-pgsql and don't have to add extensions in php.ini manually in Linux (in Windows yes), because redundancies are generated and this does not work (checked in error.log).
$ sudo apt install php-pgsql
Then you can check the existence of the extension enabled automatically in:
$ sudo nano /etc/php/7.0/apache2/conf.d/10-pdo.ini
Observations: In phpinfo() you will find the directory conf.d/ and the file error.log
GL
Just run php --ini and look for Loaded Configuration File in output for the location of php.ini used by your CLI
then check you have enabled the extensions correctly.
Copy libpq.dll from the PHP directory to Apache24\bin (or wherever your installation could be).
Getting this warning on a custom-compiled version of PHP7, even when running php -v.
Tried all solutions posted. What could cause this?
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/pdo_mysql.so' - /usr/lib/php/20151012/pdo_mysql.so: undefined symbol: mysqlnd_allocator in Unknown on line 0
There are similar questions to this, but they are not quite the same problem - they generally relate to a missing mcrypt library. I confirmed that mycrypt is in fact loaded, as well as pdo_mysql when printing out phpinfo().
Is there something wrong with the order? Also, this is for PHP 7, which I believe has different formats for ini files.
Edit: Following instructions here for recompile. Not too experienced in this: http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
Also, removed MySQL completely with apt-get purge. No luck with anything.
I found that I had
extension=pdo_mysql
uncommented in my php.ini file and this was causing the problem. Libraries are loaded by the files in the /etc/php/7.4/cli/conf.d/ file on my system and don't need to be loaded by uncommenting lines in the php.ini file.
(Posted on behalf of the OP).
Commands performed in order; I removed MySQL and PHP completely from system then:
sudo apt-get update
sudo apt-get install php7.0
sudo apt-get install php7.0-mysql
This seems to have fixed the error. Uuuugh.
Sometimes there is an issue with not loaded correctly extensions in the php.ini file.
I had similar error and it start working only after I have added these extensions before pdo_mysql to the php.ini:
extension=mysqlnd
extension=pdo
extension=pdo_mysql
And it finally worked!
However it shows warnings that mysqlnd, PDO and pdo_mysql was loaded before, it means that pdo_mysql already enabled and can be commented out at all. For further info please check PHP Warning: Module already loaded in Unknown on line 0
I just changed my server and experience these errors below:
Fatal error: Call to undefined function mysqli_init() in /home/blacktwitter/public_html/system/database/drivers/mysqli/mysqli_driver.php on line 126
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/blacktwitter/public_html/system/database/drivers/mysqli/mysqli_driver.php:126)
Filename: core/Common.php
Line Number: 564
Backtrace:
A PHP Error was encountered
Severity: Error
Message: Call to undefined function mysqli_init()
Filename: mysqli/mysqli_driver.php
Line Number: 126
Backtrace:
Website is in Codeigniter. It works on one server very well and on the local machine too. But when I upload that website at the new server I have that errors. Of course I changed important parameters like database connection, base_url() etc.
I was suspicious about database, but I have created a new database and user etc. and changed connection info.
Why does this happen? It will be helpful to know if it is a bug at the server or at the website. Also when I create some index.html with some test code everything is fine.
It is not a bug in your application, it is just a missing driver, so, you have couple of options...
Go to your php init and uncomment the following:
extension=php_mysqli.dll
If not, try installing it at your server, it varies depending on your distribution.
Try installing php5-mysqlnd
If you cannot do it by hosting restrictions then just move to mysql driver (wont need to change other configurations or queries in CodeIgniter or anything else...)
like this (at your config file)
$db['default']['dbdriver'] = 'mysql'; (you might have mysqli now)
I just had this issue on a ubuntu16.04, php7.1 install with Codeigniter 3.
Solution was simple (if hard to find!)
sudo apt-get install php7.0-mysql
I realised that the mysql*.ini files where missing from the etc/php/7.1/mods-available directory. Not sure how it happened, but that worked for me.
If you use 7.2, simply type sudo apt-get install php7.2-mysql
Use this:
sudo apt-get install php7.*-mysqli
or
sudo phpenmod mysqli
sudo service apache2 restart
This is actually not a CodeIgniter issue but PHP installation issue.
I have installed PHP5.6 in my Linux server and is having a hard time following the googled solutions of using the ff command in order to install the missing mysqli_extension in PHP.
What I tried is but is returning the warning message: Unable to locate package php5-mysqli
sudo apt-get install php5-mysqli
However, my php version is 5.6 so I tried
sudo apt-get install php5.6-mysqli
Then it works.
The problem is php's mysql extension might not have installed, if you are using php 7, just issue the below command and install the extension,
sudo apt-get install php-mysql
Open the folder where you have installed PHP, Edit php.ini file
uncomment this line:
extension=php_mysqli.dll
I know the difference is not that big but for the ones who are running CentOS:
sudo yum install php-mysqli
sudo systemctl status httpd
We are installing the mysqli extension using yum and then restarting our httpd server for the changes to take effect, and in case you are not using httpd just replace httpd for the name of your service.
For me this was a missing line in php.ini that solved it, as I copied another php.ini file to my XAMPP installation.
Worth checking if the line: "extension=php_mysqli.dll" exist (if running Windows, but this isn't applicable for OP, as it's a Linux system), or if the "extension_dir" exists and is correct.
1、apt-get install (yum, compile install whatever) php5-mysqlnd extension.
2、if not work, make sure mysqli is loaded
root#x19-ws07-1:/etc/php5/apache2# cat /proc/31682/maps | grep mysql
if is loaded, you can see:
7f2cd3266000-7f2cd3285000 r-xp 00000000 fd:00 864561 /usr/lib/php5/20131226/mysqli.so
7f2cd69ef000-7f2cd6a2e000 r-xp 00000000 fd:00 864559 /usr/lib/php5/20131226/mysqlnd.so
3、if not loaded use php --ini to find config file
xxxx#xxxx:~$ php --ini
Configuration File (php.ini) Path: /etc/php5/apache2
Loaded Configuration File: /etc/php5/apache2/php.ini
Scan for additional .ini files in: /etc/php5/apache2/conf.d
Additional .ini files parsed: /etc/php5/apache2/conf.d/05-opcache.ini,
/etc/php5/apache2/conf.d/20-mysqli.ini
4、if not config extension, config like this and remember restart your web server
xxxx#xxxxx:~$ cat /etc/php5/apache2/conf.d/20-mysqli.ini
; configuration for php MySQL module
; priority=20
extension=mysqli.so
In Linux, you can install MySQL driver extension.
sudo apt-get install php-mysql
In Windows with XAMPP, the driver has already saved in ext directory, but you need to enable it in php.ini. You need to uncomment this line:
extension=php_mysqli.dll
You also need to check the extension directory location in php.ini. I use absolute path (not relative path) declaration to make it works.
extension_dir="your\absolute\path\to\xampp\php\ext"
For example,
extension_dir="C:\xampp\php\ext"
I tried, comment out below line in /etc/php/cli/php.ini file.
extension=php_mysqli.dll
I am using Ubuntu 16.04 on AWS-EC2 instances and PHP 7.0. This solved my problem.
In my case using Windows I had all the necessary extensions uncommented, but it wasn't loading them. Then, I checked the extension directory variable in php.ini and it was as "ext", but then I remembered I'd had a similar problem previously. So what I did was basically put the explicit directory. Something like this:
extension_dir = "C:\php\ext"
Of course the specific ext directory depends entirely on your own setup and locations.
After updating the php.ini file you just have to restart Apache to apply the changes.
If you installed your Apache manually (not using pre-packaged solutions like XAMPP or WAMPP) you just have to use these commands in either a Command Prompt or a Powershell with administrator rights.
net stop Apache2.4
net start Apache2.4
If your webserver is running with a lower version of MySQL, then you will get this error as MySQLi is not supported in MySQL < 4.1.3
It is highly recommended to go with MySQLi instead of going back to MySQL extension.
More info on php.net
I suggest you do the following:
change:
'dbdriver' => 'mysqli',
'dbprefix' => '',
to:
'dbdriver' => 'mysql',
'dbprefix' => '',
in database.php file.
I am trying to connect to my database (remote server) which has PostgreSQL installed in it. My PHP code is trying to connect to the database using pg_connect(), but I get the error saying:- "Fatal error: Call to undefined function pg_connect() in /var/www/website/functions.php on line 82".
The line 82 simply is:
$db = pg_connect($conn_string);
where $conn_string = "host=".$hostname." port=5432 dbname=".$dbname." user=".$db_user." password=".$db_password.""
(all variables defined earlier)
I checked many forums and the only solution suggested was locating the php.ini file which contains a line:- extension = pgsql.so (for UNIX) and extension = php_pgsql.dll (for Windows).
This statement is supposed to be commented and the solution is to uncomment it. I have tried it but still does not change the situation. The remote server has a version later than PostgreSQL v9.0.4 installed.
I then installed PostgreSQL v8.4.8 on to my laptop and ran the website locally using MAMP. At first, Apache crashed for some odd reason, I fixed that problem but again I ended up with the same error as before i.e. Fatal error: Call to undefined function pg_connect()....
I also ran the phpinfo() and it showed that the php version does support the PostgreSQL module.I have spent an entire day searching for the solution but have been unsuccessful. This is my first project developing a website and I am out of wits. Any kinda help will be highly appreciated.
phpinfo() gives me a huge list of things at the terminal but the listings relevant to PostgreSQL are as follows:-
pdo_pgsql
PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 9.0.4
Module version => 1.0.2
Revision => $Id: pdo_pgsql.c 306939 2011-01-01 02:19:59Z felipe $
pgsql
PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 9.0.4
Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited
I had restarted MAMP after every edit I made since it was mentioned in every post I have read so far. I believe that resets both Apache and php.
'pqsql.so' (which is the UNIX equivalent of 'php_pqsql.dll' in Windows) is present in the 'extension' directory. I also copy-pasted the 'pqsql.so' file on to the Apache/bin directory but it did not give me any change.
I am not running php in the command line primarily. I just was curious to see what phpinfo() would give me relevant to pgsql which I have mentioned in my reply above.
I am still working on the tools you have mentioned and will respond as soon as I get any results.
Thanks,
H
You need to install the php-pgsql package or whatever it's called for your platform. Which I don't think you said by the way.
On Ubuntu and Debian:
sudo apt-get install php-pgsql
Easy install for ubuntu:
Just run:
sudo apt-get install php5-pgsql
then
sudo service apache2 restart //restart apache
or
Uncomment the following in php.ini by removing the ;
;extension=php_pgsql.dll
then restart apache
Fatal error: Call to undefined function pg_connect()...
I had this error when I was installing Lampp or xampp in Archlinux,
The solution was edit the php.ini, it is located in /opt/lampp/etc/php.ini
then find this line and uncomment
extension="pgsql.so"
then restart the server apache with xampp and test...
Edit. I just noticed you were mentionning MAMP. My advice is for Windows but may be useful if you know what corresponding tools to use.
Things to try:
Have you restarted PHP and Apache since your editing of php.ini?
Is the php_pgsql.dll found in your php\ext directory?
Are you running php as a module? If so, try copying the php_pgsql.dll
file in the Apache\bin directory.
Are you running PHP from the command line with a flag specifying a
different php.ini file?
You could try using a tool such as Sysinternals' Filemon to view what
files are attempting to be accessed when running PHP.
You could try using a tool such as Dependency Walker to look at the dependencies for the postgreSQL DLL, in case you have a missing dependency. Quick search brought up ldd for Unix.
Add 'PHPIniDir "C:/php"' into the httpd.conf file.(provided
you have your PHP saved in C:, or else give the location where PHP
is saved.)
Uncomment following 'extension=php_pgsql.dll' in
php.ini file
Uncomment ';extension_dir = "ext"' in php.ini
directory
I had the same symptom in win7. I got this script:
<?php
phpinfo();
pg_connect("blah");
When I executed the phpinfo.php script via apache (http://localhost/phpinfo.php) then I got the error message:
Call to undefined function pg_connect() in...
When I executed the same script from command line (php phpinfo.php) then I got the expected message:
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: missing "=" after "blah"
In both cases the expected php.ini was used:
Loaded Configuration File C:\Program Files (x86)\php\php.ini
but the pgsql section was completely missing from the phpinfo in case of the apache-based execution and it was present in the command-line-based execution.
The solution was that I added the following line to the apache httpd.conf:
LoadFile "C:/Program Files (x86)/php/libpq.dll"
It seems that for some reason this file is not loaded automatically when apache runs the php script but it is loaded if I run the php script from the command line.
I hope it helps.
You have to follow these steps:
Open the php configuration file, which is located in the following directory
C: \ xampp \ php \ php.ini
Within that file search the extension section and uncomment the following lines
extension = php_pdo_pgsql.dll
extension = php_pgsql.dll
and restart your apache
I also had this problem on OSX. The solution was uncommenting the extension = pgsql.so in php.ini.default and deleting the .default suffix, since the file php.ini was not there.
If you are using XAMPP, the php.ini file resides in /XAMPP/xampfiles/etc
install the package needed.
if you use yum:
yum search pgsql
then look at the result and find anything that is something like 'php-pgsql' or something like that. copy the name and then:
yum install *paste the name of the package here*
For php 5.4 on Centos 6.10, we include these lines in php.ini
extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo.so
extension=/opt/remi/php54/root/usr/lib64/php/modules/pgsql.so
extension=/opt/remi/php54/root/usr/lib64/php/modules/pdo_pgsql.so
It works.
I encountered this error and it ended up being related to how PHP's extension_dir was loading.
If upon printing out phpinfo() you find that under the PDO header PDO drivers is set to no value, you may want to check that you are successfully loading your extension directory as detailed in this post:
https://stackoverflow.com/a/14786808/2578505
On Gentoo, use USE flag postgres in /etc/portage/make.conf and re emerge "emerge php"
Uncommenting extension=php_pgsql.dll in the php.ini configuration files does work but, you may have to also restart your XAMPP server to finally get it working. I had to do this.
The solution has to do with the fact that your the file holding your php configurations. i.e php.ini has uncommented the extension responsible for acting as the middleman between php and postgres, by placing a ";" in front of the statement "extension=pdo_pgsql"
Quick Fix
Open the php.ini file in your favourite editor. (atom 🙌)
Search for the line "extension=pdo_pgsql", which is under the "Dynamic Extensions" section. (a simple ctrl + f) would get you there quick.
Remove the ";" in front of the line ";extension=pdo_pgsql".
Restart your server.
Go fix more errors like a rock star. 👍
If you got php5.6 using the ppa repository http://ppa.launchpad.net/ondrej/php/ubuntu,
then you should install the package using:
sudo apt install php5.6-pgsql
Finally, if you use apache2, restart it:
sudo service apache2 restart
For those of you who have this problem with PHP 5.6, you can use the following command:
yum install php56w-pgsql
For a list of more package names for PHP 5.6, open the following link and scroll down to packages:
PHP 5.6 on CentOS/RHEL 7.0 and 6.6 via Yum
In windows OS find this in php.ini "php_pgsql.dll" and remove the ";" in the extension then that's it :) Cheeers!
This question already has answers here:
Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL
(22 answers)
Closed 7 years ago.
I've seen a few similar questions to this one, but they seemed to be primarily addressing different environments than what I am using, so I hope this isn't a repeat.
I am trying to do a test migration in Laravel 4.2 on my local server using XAMPP on Windows 7. When I try to run php artisan migrate, I get the error:
[PDOException]
could not find driver
migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--pac
kage[="..."]] [--pretend] [--seed]
Most other suggestions I've seen are in regards to the php.ini file, but I do have the necessary line uncommented:
extension=php_pdo_mysql.dll
And it appears to be running when I view my phpinfo():
mysqlnd
...
API Extensions mysql,mysqli,pdo_mysql
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.11-dev - 20120503 - $Id:
bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $
My only thought is that it might be an issue with my running XAMPP on ports 81 and 3307 instead of the default 80 and 3306 (although I believe I do have XAMPP's config files correctly configured, since I've been able to run other applications fine on these ports). Are there any other Laravel config files I might have missed though?
Edit 11/15
I see that there was a similar question asked here, but for what it's worth it appears that that error for that user had occurred after the installation process (it appeared to have been resolved through Laravel instead of through the php.ini file). This specific problem appears to have been related to the installation process itself, and appears to have help at least a few people that also were unable to find the specific answer in other versions of the question.
So it did turn out to be a problem with the PATH settings. Thank you very much #ykbks. The link provided wasn't quite clear on how to diagnose it though, so just to expand on that in hopes it helps someone in the same position, from the command line I ran
C:\>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none) <<Problem
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
So I kept changing the php.ini file that wasn't being seen by the system. I added XAMPP's php folder to the PATH and the migrate ran perfectly.
I had this error using Laravel 5.1 on Linux Ubuntu 15.10 with php5-fpm and NGINX. Seems like the problem comes due to missing PHP module. I resolved this installing on my system php5-mysql. Simply run:
sudo apt-get install php5-mysql
On Windows this can be fixed I hope including the MySQL module in php.ini file. On XAMPP this should be included by default.
This can happen for a Number of reasons.
Either the Default DB type is not set (config/database.php),
or the Extension is not enabled,
or you HAVE enabled the extension but have NOT restarted XAMPP,
or the PATH settings under environment settings are not properly defined.
I suggest you check out this answer which may solve the issue: https://stackoverflow.com/a/25336292/2745485
Regards.