PDO Driver cannot connect to sql - using xampp - php

I have been looking for a solution for this for hours now and I found a lot of solutions, but unfortunately none of them worked.
The error I am getting is :
Fatal error: Uncaught PDOException: could not find driver in
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc:124 Stack
trace: #0
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc(124):
PDO->__construct('sqlsrv:Server=l...', 'sa', 'PWHERE...', Array) #1
C:\xampp\htdocs\site\includes\database\database.inc(1689):
DatabaseConnection_sqlsrv->__construct(Array) #2
C:\xampp\htdocs\site\includes\database\database.inc(1479):
Database::openConnection('xilenacc', 'default') #3
C:\xampp\htdocs\site\includes\database\database.inc(2350):
Database::getConnection('default') #4
C:\xampp\htdocs\site\includes\lock.inc(167): db_query('SELECT expire,
...', Array) #5 C:\xampp\htdocs\site\includes\lock.inc(146):
lock_may_be_available('schema:runtime:...') #6
C:\xampp\htdocs\site\includes\bootstrap.inc(433):
lock_acquire('schema:runtime:...') #7
C:\xampp\htdocs\site\includes\bootstrap.inc(455):
DrupalCacheArray->set(Array) #8 [internal function]:
DrupalCacheArray->__destruct() #9 {main} thrown in
C:\xampp\htdocs\site\includes\database\sqlsrv\database.inc on line
124`
This is line 124 at database.inc:
PDO::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);`
<br>
Information on what I am using:
PHP Version: 7.0.25
Mssql express 2016
Windows Server 2012
If I can provide further information, please let me know.
What I tried:
Downloading SQLSRV30 from microsoft website and putting the extensions in php -> Result: After putting the dll names in php.ini, I restarted apache and checked phpinfo(), I didn't find sqlsrv.
I double checked the information I have in settings.php - they are correct,
I even tried changing my sql pw because I thought it might be causing this,
but it didn't work.

Finally after hours of googling, I found a solution that actually worked even though it doesn't look so important.
The solution that worked with me is to install Microsoft Redistributable 2012. Kinda weird but worked!

Related

Table 'database.wp_options' doesn't exist error log in WordPress [duplicate]

This question already has answers here:
Unknown column 'wp_' in 'field list' when running WordPress on PHP 8.1
(3 answers)
Closed last year.
Please I need help its my firs time to setup and I can't install wordpress in my localhost server IIS I'm using latest PHP, MySQL and IIS.
Here is my Debug LOG:
[15-Jan-2022 02:53:10 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Table 'cswebsite.wp_options' doesn't exist in C:\inetpub\wwwroot\cswebsite\wp-includes\wp-db.php:2056
Stack trace:
#0 C:\inetpub\wwwroot\cswebsite\wp-includes\wp-db.php(2056): mysqli_query(Object(mysqli), 'SELECT option_v...')
#1 C:\inetpub\wwwroot\cswebsite\wp-includes\wp-db.php(1945): wpdb->_do_query('SELECT option_v...')
#2 C:\inetpub\wwwroot\cswebsite\wp-includes\wp-db.php(2581): wpdb->query('SELECT option_v...')
#3 C:\inetpub\wwwroot\cswebsite\wp-includes\functions.php(1734): wpdb->get_var('SELECT option_v...')
#4 C:\inetpub\wwwroot\cswebsite\wp-includes\load.php(752): is_blog_installed()
#5 C:\inetpub\wwwroot\cswebsite\wp-settings.php(159): wp_not_installed()
#6 C:\inetpub\wwwroot\cswebsite\wp-config.php(97): require_once('C:\inetpub\wwwr...')
#7 C:\inetpub\wwwroot\cswebsite\wp-load.php(50): require_once('C:\inetpub\wwwr...')
#8 C:\inetpub\wwwroot\cswebsite\wp-admin\install.php(36): require_once('C:\inetpub\wwwr...')
#9 {main}
thrown in C:\inetpub\wwwroot\cswebsite\wp-includes\wp-db.php on line 2056
I had the same issue trying to make a fresh local install of WP with no previous versions installed.
I saw a couple of posts (example) suggesting it's a PHP version problem with WP5.8.x, and reverting to PHP8.0 works. And guess what, it did.
(I was using homebrew, and 'brew install php#8.0' doesn't create the symlinks you need to do a 'brew link php#8.0' afterwards. Also, it put libphp.so in a different place (why, Lord, why?) so you need to change your httpd.conf as well. Oh, and you probably need to do 'brew remove php' before you start the downgrade)
Hope this works for you...

WooCommerce php 8.1 + WordPress 5.7.2

I have an issue with using new PHP 8.1 on WordPress 5.7.2. Everything work just fine, until turn on WooCommerce 5.3.0. Then whole site fall down.
Here is error message what I'm getting:
Fatal error: Uncaught Error: Call to undefined function putenv() in
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37
Stack trace: #0
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49):
WC_Regenerate_Images_Request->__construct() #1
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/class-wp-hook.php(292):
WC_Regenerate_Images::init('') #2
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/class-wp-hook.php(316):
WP_Hook->apply_filters(NULL, Array) #3
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/plugin.php(484):
WP_Hook->do_action(Array) #4
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-settings.php(560):
do_action('init') #5
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-config.php(90):
require_once('/data/web/virtu...') #6
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-load.php(37):
require_once('/data/web/virtu...') #7
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-admin/admin.php(34):
require_once('/data/web/virtu...') #8
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-admin/plugins.php(10):
require_once('/data/web/virtu...') #9 {main} thrown in
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php
on line 37
Please does anyone know, if there is any problem with compatibility? I didn't find any information about it.
This isn't a problem with 8.1 over 8.0.
PHP has a function blacklist.
Remove putenv from the blacklist. This worked for me when I received this error using PHP 8.0.
WordPress is not ready yet for PHP 8.1. If you install on 8.1 you can show dozens of errors about deprecated methods like ltrim() or count, even if install WordPress 5.8.2. You can fix most of the issues in this reference
but its not worth that. My advice is you wait for the compatible version of Wordpress.
Remove or change this lines from php ini or config file:
//either put colon or remove this whole line
;disable_functions = passthru,exec,putenv,system,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv

Domain is currently unable to handle this request on a Laravel project

Whenever I try to access my app online I get the following error.
[the-domain] is currently unable to handle this request.
I'm currently lost and don't even know what the problem is I've replicated my local environment on my server and the problem still persists, probably something I'm missing.
Here is my current config.
Laravel 5.7
PHP 7.2.9
Heres the stack trace form laravel.log:
[2018-09-30 12:18:28] staging.ERROR: syntax error, unexpected '|', expecting variable (T_VARIABLE) {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\F$
[stacktrace]
#0 /var/www/avanzi/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile('/var/www/invite...')
#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('Illuminate\\\\Supp...')
#2 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(22): spl_autoload_call('Illuminate\\\\Supp...')
#3 /var/www/avanzi/vendor/composer/ClassLoader.php(444): include('/var/www/invite...')
#4 /var/www/avanzi/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile('/var/www/invite...')
#5 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('Illuminate\\\\Data...')
#6 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(35): spl_autoload_call('Illuminate\\\\Data...')
#7 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(572): Illuminate\\Database\\DatabaseServiceProvider->register()
#8 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\\Foundation\\Application->register(Object(Illumin$
#9 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(548): Illuminate\\Foundation\\ProviderRepository->load(Array)
#10 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\\Foundation\\Application->registerConfi$
#11 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(206): Illuminate\\Foundation\\Bootstrap\\RegisterProviders->bootstrap(O$
#12 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#13 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#14 /var/www/avanzi/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Ob$
#15 /var/www/avanzi/public/index.php(58): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#16 {main}
"}
NB: This works perfectly fine in my local environment with the same PHP and Laravel version.
So I finally got it figured out for my use case.
I had the right PHP version installed but haven't enabled the extensions required by Laravel yet, so to fix this I had to go to the php.ini file for my currently installed and active PHP version and enable those extensions, here is a list of the required PHP extensions for a Laravel 5.7 project.
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
With all these extensions installed your PHP configuration should be good to go.

antonioribeiro/firewall package throwing errors after upgrading to laravel 5.2.5?

I am working on a laravel application and decided to use antonioribeiro/firewall to manage IP restrictions throughout my application. The package is awesome and worked like a charm. Until recently when I upgraded to the latests laravel version 5.2.5 when the package started throwing and error, the stack to which I am pasting below:
[2015-12-29 09:23:20] local.ERROR: exception 'BadMethodCallException' with message 'Method filter does not exist.' in /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:81
Stack trace:
#0 /home/vagrant/Code/archive/vendor/pragmarx/firewall/src/Vendor/Laravel/ServiceProvider.php(163): Illuminate\Routing\Router->__call('filter', Array)
#1 /home/vagrant/Code/archive/vendor/pragmarx/firewall/src/Vendor/Laravel/ServiceProvider.php(163): Illuminate\Routing\Router->filter('fw-block-bl', '\\PragmaRX\\Firew...')
#2 /home/vagrant/Code/archive/vendor/pragmarx/firewall/src/Vendor/Laravel/ServiceProvider.php(67): PragmaRX\Firewall\Vendor\Laravel\ServiceProvider->registerFilters()
#3 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(531): PragmaRX\Firewall\Vendor\Laravel\ServiceProvider->register()
#4 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(74): Illuminate\Foundation\Application->register(Object(PragmaRX\Firewall\Vendor\Laravel\ServiceProvider))
#5 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(507): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(208): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /home/vagrant/Code/archive/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(105): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 /home/vagrant/Code/archive/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}
Now I am not an expert but I think this line:
$this->app['router']->filter('fw-block-bl', '\PragmaRX\Firewall\Filters\Blacklist');
is responsible for throwing the error. My best guess is that maybe filters are deprecated in 5.2.5 and there is no longer a filter method or maybe it was renamed to something else. In either case I don't know how to fix this. I am not using the filters that ship with the package as it is. I have written my own custom middleware to work with. How do I go around this problem?
So I had not updated to the newer version of the package available and the even more frustrating problem I faced was that the newer package bundled the older version (~0.5) of the support package from the same user and I had to forcefully update to the newer version (~0.6) of the support package too.
Github issue

Install impresspages to localhost - problems with db connection

When i try to install impresspages on localhost in Database installation i see this:
Can't connect to database.
I try to solve this problem by installing it on hosting(its install with no problems) and then transfer it to localhost with all database, and i edit config file. And when i go to home page i saw this:
Fatal error: Uncaught exception 'Ip\Exception\Db' in C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php:258 Stack trace: #0 C:\www\Apache2\htdocs\ip\Ip\Db.php(28): Ip\Db->getConnection() #1 C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php(258): Ip\Db->__construct() #2 C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php(226): Ip\ServiceLocator::loadService('db') #3 C:\www\Apache2\htdocs\ip\Ip\Functions.php(379): Ip\ServiceLocator::db() #4 C:\www\Apache2\htdocs\ip\Ip\Internal\Plugins\Model.php(316): ipDb() #5 C:\www\Apache2\htdocs\ip\Ip\Internal\Plugins\Service.php(9): Ip\Internal\Plugins\Model::getActivePluginNames() #6 C:\www\Apache2\htdocs\ip\Ip\Dispatcher.php(140): Ip\Internal\Plugins\Service::getActivePluginNames() #7 C:\www\Apache2\htdocs\ip\Ip\Application.php(153): Ip\Dispatcher->_bindApplicationEvents() #8 C:\www\Apache2\htdocs\ip\Ip\Application.php(319): Ip\Application->_handleOnlyRequest(Object(Ip\Request), Array, false) #9 C:\www\Apache2\htdocs\ip\Ip\Application.php(413): Ip\Application->handleRequest(Object(Ip\Request), Ar in C:\www\Apache2\htdocs\ip\Ip\ServiceLocator.php on line 258
Looks like the MySQL extension for PHP is not installed or enabled. See http://php.net/manual/en/mysql.installation.php for more information.

Categories