Я получаю эту ошибку в почтальоне во время работы с API PHP REST: < /p>
Фактальная ошибка < /b>: uncaught pdoexception: sqlstate [42000]: синтаксическая ошибка или нарушение доступа: 1064 У вас есть ошибка в
your SQL Syntax; Проверьте руководство, которое соответствует вашей версии сервера MariaDB для правильного синтаксиса для использования вблизи
'listing_name =' name ',
address =' test ',
po ...' в строке 2 В C: \ xampp \ htdocs \ project \ dtb \ models \ listing.php: 137
Stack Trace: < /p>
< /blockquote>
Вот моя модель < /p>
// Create Post
public function create(){
// create query
$query = 'INSERT INTO ' .
$this->table .
'SET
listing_name = :listing_name,
address = :address,
postal_code = :postal_code,
google_id = :google_id,
website = :website,
tag_array = :tag_array,
area_array = :area_array';
// Prepare Statement
$stmt = $this->conn->prepare($query);
// Clean Data
$this->listing_name = htmlspecialchars(strip_tags($this->listing_name));
$this->address = htmlspecialchars(strip_tags($this->address));
$this->postal_code = htmlspecialchars(strip_tags($this->postal_code));
$this->google_id = htmlspecialchars(strip_tags($this->google_id));
$this->website = htmlspecialchars(strip_tags($this->website));
$this->tag_array = htmlspecialchars(strip_tags($this->tag_array));
$this->area_array = htmlspecialchars(strip_tags($this->area_array));
// Bind Data
$stmt->bindParam(':listing_name', $this->listing_name);
$stmt->bindParam(':address', $this->address);
$stmt->bindParam(':postal_code', $this->postal_code);
$stmt->bindParam(':google_id', $this->google_id);
$stmt->bindParam(':website', $this->website);
$stmt->bindParam(':tag_array', $this->tag_array);
$stmt->bindParam(':area_array', $this->area_array);
// Execute Query
if($stmt->execute()) {
return true;
}
// Print Error is Something Goes Wrong
printf("Error: %s ", $stmt->error);
}
< /code>
и это create.php < /p>
Подробнее здесь: https://stackoverflow.com/questions/675 ... 000-syntax
PHP REST API Postman Fatal Error Unaught PdoException: SQLState [42000]: Синтаксический ошибка или нарушение доступа: 10 ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение