MySQLI Update sets +1 correct form and characters

EDIT; there is no error, and everything else works, but the update I just do not get +1 :( nothing is updated. Maybe because I use the wrong quotation marks?

I am searching on the Internet, some people use the following type of query

UPDATE `attempts` SET `fails` = fails+1 WHERE id='3'"

I'm confused because others use

UPDATE `attempts` SET `fails` = `fails` +1 WHERE id='3'"

and

UPDATE `attempts` SET `fails` = +1 WHERE id='3'"

Which form is correct when pasted into MySQL, and I mean the characters used as well. Some use characters that some others don't, and that bothers me. These questions are about characters and the correct form when inserting data

You just need to know what the correct form is, when to use `` when '' and when "" only in this request

+4
2

", , - Cardinale 4 "

:

fails ​​ ; .

fails INT 1 do fails INT 10

, ,

WHERE id='3'

WHERE id=3

: PDO ; .

<?php 
$servername = "xxx"; // Modify
$username   = "xxx"; // these
$password   = "xxx"; // for
$dbname     = "xxx"; // your own

try {

    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $query = 'UPDATE `your_table` SET col = col + 1 WHERE id = :id';
    $stmt = $conn->prepare( $query );
    $stmt->execute(array(':id' => $userid));

     }
catch(PDOException $e) {
     echo "Error: " . $e->getMessage();
}
$conn = null;
+3
  • ` ,
  • '

, , , id , :

UPDATE `attempts` SET `fails` = `fails` + 1 WHERE id = 3

SET fails = +1 fails, 1.

+1

All Articles