Pourquoi ai-je cette erreur:L'objet n'a pas pu être converti en chaîne?
Catchable fatal error: Object of class Card could not be converted to string in /f5/debate/public/Card.php on line 79
Voici le code:
public function insert()
{
$mysql = new DB(debate);
$this->initializeInsert();
$query = "INSERT INTO cards
VALUES('$this->$type','$this->$tag','$this->$author->$last','$this->$author->$first',
'$this->$author->$qualifications','$this->$date->$year','$this->$date->$month',
'$this->$date->$day','$this->$title', '$this->$source', '$this->$text')";
$mysql->execute($query);
}
(ligne 79 est le $query
et la fonction fait partie de la classe Card
)
Toutes les déclarations de Card
:
public $type;
public $tag;
public $title;
public $source;
public $text;
public function __construct() {
$this->date = new Date;
$this->author = new Author;
}
Après la ligne changement de 79 à ceci:
$query = "INSERT INTO cards
VALUES('$this->type','$this->tag','$this->author->last','$this->author->first',
'$this-$author->qualifications','$this->date->year','$this->date->month','$this->date->day',
'$this->title', '$this->source', '$this->text')";
Je reçois maintenant cette erreur:
Catchable fatal error: Object of class Author could not be converted to string in /f5/debate/public/Card.php on line 79
C'est à cause de '$ this- $ author-> qualifications' – quantumSoup