• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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