follow us on google+ follow us feedburner

FORUM

Fatal error



Posted by: giovani
April 21, 2013 05:27PM
Bonjour,

J'ai un problème avec une class PHP, MYSQL. Elle ne fonctionne pas avec EasyPHP-12.
Alors qu'en ligne elle fonctionne très bien ainsi qu'avec mon système Linux en local.
Avez-vous une idée pour résoudre ce problème ?

Merci pour votre aide

Theobaldus

<?php
class crud {
private $db;

public function __set($name, $value) {
switch($name) {
case 'username':
$this->username = $value;
break;

case 'password':
$this->password = $value;
break;

case 'dsn':
$this->dsn = $value;
break;

default:
throw new Exception("$name is invalid");
}
}

public function __isset($name) {
switch($name) {
case 'username':
$this->username = null;
break;

case 'password':
$this->password = null;
break;
}
}

public function conn() {
isset($this->username);
isset($this->password);
if (!$this->db instanceof PDO) {
(40) ---- $this->db = new PDO($this->dsn, $this->username, $this->password);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}

public function dbSelect($table, $fieldname=null, $id=null) {
$this->conn();
$sql = "SELECT * FROM `$table` WHERE `$fieldname`=:id";
$stmt = $this->db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

public function rawSelect($sql) {
$this->conn();
return $this->db->query($sql);
}

public function rawQuery($sql) {
$this->conn();
$this->db->query($sql);
}
} /*** end of class ***/
?>

<?php
$crud = new crud();
$crud->dsn = "mysql:dbname=MABASE;host=localhost";
$crud->username = 'MON LOGIN';
$crud->password = 'XXXXXXXXXXXXXX';
?>
<?php
$records = $crud->rawSelect('SELECT id, date, titre, news FROM MA TABLE ORDER BY `id` DESC LIMIT 0, 40');
$rows = $records->fetchAll(PDO::FETCH_ASSOC);

foreach($rows as $row) {

}
?>

Fatal error: in D:\EasyPHP-12.1\www\TEST\REQUIRE\Class.php on line 40
Options: ReplyQuote
Posted by: giovani
April 28, 2013 03:53PM
Bonjour,

J'ai trouvé, c'était une erreur dans les privilèges.

Merci tout de même

Giovani
Options: ReplyQuote


Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.