API / Fatal error: Uncaught PDOException: Base table or view not found

Hi there,

I’m encountering a PHP fatal error when requesting any phpList API endpoints:

<b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'examplecom_phpl141.phplist_config' doesn't exist in /home/examplecom/phplist.example.com/base/config/parameters.php:29
Stack trace:
#0 /home/examplecom/phplist.example.com/base/config/parameters.php(29): PDO-&gt;prepare('select value fr...')
#1 /home/examplecom/phplist.example.com/base/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php(41): include('/home/examplecom/...')
#2 /home/examplecom/phplist.example.com/base/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php(44): Symfony\Component\DependencyInjection\Loader\ProtectedPhpFileLoader-&gt;Symfony\Component\DependencyInjection\Loader\{closure}('/home/examplecom/...')
#3 /home/examplecom/phplist.example.com/base/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/DelegatingLoader.php(40): Symfony\Component\DependencyInjection\Loader\PhpFileLoader-&gt;load('/home/examplecom/...', NULL)
#4 /home/examplecom/phplist.ex in <b>/home/examplecom/phplist.example.com/base/config/parameters.php</b> on line <b>29</b><br />

Note: I redacted original domain name and replaced it with example

It’s a clean and brand new phpList 3.6.6 install through cPanel. The admin area works great apparently as well as the public pages. The fatal error is there before and after API activation and no matter if it’s an authenticated request or not.

I checked with phpMyAdmin and examplecom_phpl141 table exists, but of course, not examplecom_phpl141.phplist_config table mentioned in the first line (If I understand the error correctly).
For practical reason, this is line #29 of ./base/config/parameters.php:
$statement = $pdo->prepare("select value from phplist_config where value = :value");

I also looked at ./config/config.php and everything looks good to me (credentials, table prefix, etc.).

Finally phpList 3.6.6 is running on PHP 7.4 and the database server is MariaDB 10.3.32.

Does anyone have an idea how to solve this problem?


Edit: the issue is reported here https://github.com/phpList/phplist3/issues/583

@b7cb1 It appears that the code in parameters.php is using a fixed table prefix ‘phplist_’ set as this line in config.php

$table_prefix = 'phplist_';

Sorry, just realised that is explained in the linked GitHub issue.

Thanks a lot @duncanc ! Yes, I found the related issue on Github. Now I understand what the primary error is. Unfortunately, fixing it leads to an Internal Server Error (500) as mentioned in the thread by others.

@b7cb1 Are you using php 8.1? I found that I had to revert to 7.4. The 500 error seems to be caused by a php 8.1 change that is not backward compatible.

I also had to create an empty composer.json file in the lists/base directory. Up to phplist release 3.6.2 that was present but since then has not been. See https://github.com/phpList/rest-api/issues/136

1 Like

A post was split to a new topic: REST API not working with php 8