• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue PHP Fatal error: Uncaught Error:

protonplsk

New Pleskian
Hi,

I have an error on my site in php, the mariadb database does not load the elements. The following error appears in the logs:

[AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined method PDOStatement::prepare() in /var/www/vhosts/pmfermetures.com/vibrant-payne.185-63-174-144.plesk.page/DB/requests_bdd.php:8\nStack trace:\n#0 /var/www/vhosts/pmfermetures.com/vibrant-payne.xxx-xx-xxx-xxx.plesk.page/index.php(4): include_once()\n#1 {main}\n thrown in /var/www/vhosts/pmfermetures.com/vibrant-payne.xxx-xx-xxx-xxx.plesk.page/DB/requests_bdd.php on line 8']

However pdo is activated and the php is at the correct version.

This code works on another server under Ubuntu with Apache

<?php
class DbConnexion
{
private $host = "localhost";
private $dbName = "";
private $user = "";
private $password = "";
protected $bdd;
public function __construct()
{
$this->connexion();
}
protected function connexion()
{
try {
$this->bdd = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->dbName, $this->user, $this->password);
$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$this->bdd->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
}
protected function getmyDb()
{
if ($this->bdd instanceof PDO)
{
return $this->bdd;
}
}
}

And for requests_bdd.php :

/*Request Data*/
$req_data = $dbh->prepare('SELECT * FROM data WHERE id = 1');
$req_data->execute();
$result_data = $req_data->fetch(PDO::FETCH_ASSOC);

Thanks for any help.
 
Hi,

I have an error on my site in php, the mariadb database does not load the elements. The following error appears in the logs:

[AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined method PDOStatement::prepare() in /var/www/vhosts/pmfermetures.com/vibrant-payne.185-63-174-144.plesk.page/DB/requests_bdd.php:8\nStack trace:\n#0 /var/www/vhosts/pmfermetures.com/vibrant-payne.xxx-xx-xxx-xxx.plesk.page/index.php(4): include_once()\n#1 {main}\n thrown in /var/www/vhosts/pmfermetures.com/vibrant-payne.xxx-xx-xxx-xxx.plesk.page/DB/requests_bdd.php on line 8']

However pdo is activated and the php is at the correct version.

This code works on another server under Ubuntu with Apache

<?php
class DbConnexion
{
private $host = "localhost";
private $dbName = "";
private $user = "";
private $password = "";
protected $bdd;
public function __construct()
{
$this->connexion();
}
protected function connexion()
{
try {
$this->bdd = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->dbName, $this->user, $this->password);
$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$this->bdd->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
}
protected function getmyDb()
{
if ($this->bdd instanceof PDO)
{
return $this->bdd;
}
}
}

And for requests_bdd.php :

/*Request Data*/
$req_data = $dbh->prepare('SELECT * FROM data WHERE id = 1');
$req_data->execute();
$result_data = $req_data->fetch(PDO::FETCH_ASSOC);

Thanks for any help.
Your request have not any relation with plesk panel....suggere you that search solution in programming forums : Call to undefined method PDOStatement::Prepare() - Google Suche
 
Back
Top