You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.
I used this layer to create a PHP lambda API. I then tried to create a PDO and connect it to a MySQL database. I got the following error
"Uncaught PDOException: could not find driver in /var/task/index.php"
My php.ini file contains the following:
extension=json.so
extension=mysql.so
extension=pdo_mysql.so
extension=pdo.so
extension=php_pdo_mysql.dll
extension=pdo_mysql.dll
Here is my index.php code for creating the DB
$conn = null;
I'm seeing the same or similar, its not that it can't find the extension but it doesn't seem to be compiled properly:
undefined symbol: mysqlnd_allocator
[Sun Aug 30 20:24:07 2020] PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /opt/lib/php/7.3/modules/pdo_mysql.so (/opt/lib/php/7.3/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /opt/lib/php/7.3/modules/pdo_mysql.so.so (/opt/lib/php/7.3/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 |
The solution is quite simple actually, in your php.ini reorder your extensions so that the mysqlnd is loaded first, and any mysql related extensions are last.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I used this layer to create a PHP lambda API. I then tried to create a PDO and connect it to a MySQL database. I got the following error
"Uncaught PDOException: could not find driver in /var/task/index.php"
My php.ini file contains the following:
extension=json.so
extension=mysql.so
extension=pdo_mysql.so
extension=pdo.so
extension=php_pdo_mysql.dll
extension=pdo_mysql.dll
Here is my index.php code for creating the DB
$conn = null;
$conn = new PDO('mysql:host=' . $host . ';dbname=' . $db_name, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
The text was updated successfully, but these errors were encountered: