-2

this is my dao file

<?php

require_once( __DIR__ . '/DAO.php');

class insertVoteDAO extends DAO {

  public function insertVote1() {
      $sql = "UPDATE `ic_items` SET `flames`+1 WHERE id=1";
      $stmt = $this->pdo->prepare($sql);
      $stmt->execute();
      return $stmt->fetch(PDO::FETCH_ASSOC);
      }
    }
?>

and in my index.php I do this:

 <?php
require_once( __DIR__ . '/dao/insertVoteDAO.php');
$voteDAO = new insertVoteDAO();

      if (!empty($_POST)) {
      $insertVote = $voteDAO->insertVote1();
    }
     ?>

This is the error I get:

Fatal error: Uncaught PDOException: 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 '+1 WHERE id=1' at line 1 in /Applications/MAMP/htdocs/backend/major-IC/dao/insertVoteDAO.php:9 Stack trace: #0 /Applications/MAMP/htdocs/backend/major-IC/dao/insertVoteDAO.php(9): PDO->prepare('UPDATE `ic_item...') #1 /Applications/MAMP/htdocs/backend/major-IC/collection.php(72): insertVoteDAO->insertVote1() #2 {main} thrown in /Applications/MAMP/htdocs/backend/major-IC/dao/insertVoteDAO.php on line 9

It says I do something wrong with syntax in my query.

I hope someone can help me.

Sven Z
  • 183
  • 1
  • 10

2 Answers2

0

This line is wrong at flames+1:

$sql = "UPDATE ic_items SET flames+1 WHERE id=1";

It should be

$sql = "UPDATE ic_items SET flames = flames+1 WHERE id=1";

Javier S
  • 379
  • 3
  • 13
0

Agreed with BanNsS1, you can check the following link for further reference: Increment a database field by 1