PDO Exception could not find driver - php

I know this question have been asked a thousand of times, but I can't find a solution. I'm running Symfony 2 with a PostgreSql database (php running in MAMP, and PG DB on an another port and install).
I was running well (could have install the DB using the app/console create cmd) however now I can't use it anymore for updating the schema. Got the error :
PDO Exception, could not find driver error
I tried everything:
Php.ini verification : OK
using the same in the CLI and phpInfo();
PDO verification in phpInfo : drivers enabled for pgSQL mySQL etc...
Restart Mamp + OSX apache server : OK

Found a solution,
I just made an alias in my .bash_profile to the php used by the server to be sure that the CLI will use the good one.
Alias PHP -> Mamp CLI
alias phpmamp='/Applications/MAMP/bin/php/php5.4.4/bin/php'
Now it works.

Related

How to enable pdo_mysql in Azure?

I'm buildig a simple web application in Laravel 8 using PHP 7.4 and Azure web services. The app runs perfectly on my local machine, but once I try to push my app to Azure I'm getting a PHP 500 error for all pages where some sort of querying is needed.
It turns out that I'm missing a pdo_mysql driver that hasn't been enabled when setting up our Linux server. I've been looking through all the Azure documentation and I can't seem to find how to turn this pdo extension on.
Strange thing is Azure provides us two terminals: the SSH terminal and a Bash terminal (Kudo remote execution terminal). When I run
php -m
in the SSH, the pdo_mysql module does show up in the list. I can also migrate my tables within the SSH. But once I run the same
php -m
command in the Bash terminal, the module is not showing. Migrating tables in that terminal is also not possible, because it says I'm missing the pdo_mysql driver. The Oryxbuilder that builds my application after each git deployment also notices that I'm missing the pdo_mysql driver and returns the same error.
So how can I enable this module in Azure? Can anyone please help me?
First of all i'd check to see if its enabled in the php.ini file, often located at /etc/php/{version}/cli/php.ini , cli may also be cgi or apache2.

PHP with NGINX can't connect to MySQL on Mac

I'm having some difficulty setting up Nginx with PHP and MYSQL on mac, where I cannot make any connection to the database. If I spawn a server using php -S, I can connect without problem. However Nginx running on port 8080 is unable to connect at all.
I've installed (and now uninstalled) php with brew, which might be an issue because it looks like PHP comes installed on mac. Running php -v shows me running on 7.1.16, but the brew installed version was 7.2+. I have PHP-FPM running on localhost:9000.
I've checked my php.ini files, but I only see extensions for mysqli and pdo_mysql, which I've tried to enable but still no luck.
Thanks for any help.

Sphinx search installation on linux server with mysql

I want to install and setup sphnix 2.2.3 search on my linux server with mysql, but after installation complete, unfortunately the "indexer" command not running and giving me an error that /data/test1.spl file not found (AS I configure that path in sphinx.conf file)
Please suggest any idea to continue this.

Using mssql methods (FreeTDS, PHP and Apache on Mac OS X)

I have installed FreeTDS on my Mac, but I'm having some issues connecting using mssql_connect.
First, when I run tsql -C I see that the freetds.conf directory is listed as /opt/local/etc/freetds. I have a freetds.conf file inside this directory.
Next, if I connect like this:
$connect = mssql_connect('IP_ADDRESS', 'username', 'password');
then everything works as expected. That is, I can retrieve, update, insert data from/into whichever DB I select with mssql_select_db().
If I try to connect like this:
$connect = mssql_connect('DSN_NAME', 'username', 'password');
where DSN_NAME matches a datasource specified in my freetds.conf file then I get an error and unable to connect to server: DSN_NAME which tells me that PHP isn't correctly seeing the path to my freetds.conf file.
However, if before my call I add:
putenv("FREETDSCONF=/opt/local/etc/freetds/freetds.conf");
then everything works as expected. This tells me that my freetds.conf file is formatted correctly.
I've searched all over about how to find the path that PHP thinks the freetds.conf file is in, but I can't find that.
Lastly, there are some reasons I don't want to use the IP address directly in my connection as well as why I don't want to be forced to use the putenv() method to specify the directory.
Any ideas?
Thank you.
When I installed FreeTDS I originally used MacPorts. I believe that this gave me some conflicts for where freetds.conf should have been. And even though the path for freetds.conf when running tsql -C was the actual path that I was attempting to use, when I compiled the mssql.so extension with that path PHP wouldn't recognize it.
The solution is to forget MacPorts for FreeTDS and just install FreeTDS from source. Then install the mssql.so extension from the PHP source and make sure you're using the same version that is on your system (mine was 5.3.13 under OS X Mountain Lion).
If you follow the instructions at this blog exactly you shouldn't have any issues.
A couple of final things:
I am NOT running MAMP even though the instructions mention it so it won't matter either way.
If you already did install FreeTDS via MacPorts, uninstall using: sudo port uninstall freetds +odbc and then sudo port uninstall unixODBC. Make sure you uninstall all instances of FreeTDS. If you have more than one, you'll get a notice when you run uninstall that you need to specify the version to uninstall.

Why can't CakePHP bake connect to MySQL running under EasyPHP on Windows Vista Ultimate?

I have CakePHP (cake_1.2.2.8120) and EasyPHP (3.0) installed on Windows Vista Ultimate. I followed the "baking" tutorials online and successfully set the database connection with the "cake bake" command from the CLI.
I baked the controller for my "Users" table using the "php cake.php bake controller Users" command - worked fine. However, when I tried baking the view similarly, I got this message:
Fatal error: Call to undefined function mysql_connect() in C:\Web\EasyPHP
\www\cake\cake\libs\model\datasources\dbo\dbo_mysql.php on line 374'
Also, the MySQL module is enabled for PHP on the phpMyAdmin page (web), but I can't find it in the CLI (using "php -m" from the command line) even though I've uncommented the "extension=php_mysql.dll" line in the php.ini file.
How can I fix this?
Grab XAMPP which has Apache with the MySQL and PHP modules setup and working together, as well at the MySQL and command-line versions. It just unzips to any directory, so it won't mess up any other Apache installs you have. Just be careful of any port conflicts between the different installations.
Download XAMPP
The root cause of the problem is that in EasyPHP 5.3 there isn't any php.ini file in the php folder.
Copy php.ini from EasyPHP5.3\apache to EasyPHP5.3\php to solve this nasty issue.
Copy the apache/php.ini file to php/php.ini.
I don't know EasyPHP, but it seems to be Apache-based. Check if you're using a Apache-module for the MySQL connection, as this will not work in CLI.

Categories