0
Im Anschluss an mein Code, $data[0]->persinId
von AngularJS POST-Anfrage übergebenPHP MYSQL Syntaxfehler oder Zugriffsverletzung: 1064
$idPerson=$data[0]->persinId;
$StmtQuestionType=connect_db()->query('SELECT a.`question_id` FROM answer a WHERE a.`person_id`=:PersonId');
$StmtQuestionType->bindValue(':PersonId',$idPerson);
$StmtQuestionType->execute();
aber ich bin nach immer err
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':PersonId' at line 1' in C:\xampp\htdocs\survey\insert.php:11 Stack trace: #0 C:\xampp\htdocs\survey\insert.php(11): PDO->query('SELECT a.`quest...') #1 {main} thrown in C:\xampp\htdocs\survey\insert.php on line 11
'prepare' statt' query'? – emaillenin
'query()' führt die angegebene Abfrage sofort aus. Stattdessen möchten Sie 'prepare()', dann 'bind()', dann 'execute()' ... verwenden – arkascha
Replace '$ StmtQuestionType = connect_db() -> query ('SELECT a.'question_id' FROM Antwort a WHERE a.person_id': PersonId '); 'with' StmtQuestionType = connect_db() -> prepare (' SELECT a.'question_id' FROM Antwort eines WHERE a.person_id' =: PersonId '); ' –