php - MySQLI Update set +1 the correct form and symbols -
edit; there no error , other things work updating no +1 :( nothing gets updated- maybe because using wrong quotes?
i looking on internet people uses following kind of query
update `attempts` set `fails` = fails+1 id='3'" i confused because others uses
update `attempts` set `fails` = `fails` +1 id='3'" and
update `attempts` set `fails` = +1 id='3'" which form correct 1 while inserting mysql , mean symbols used. uses symbols others don´t , makes me confused. questions symbols , correct form when inserting data
just need know correct form when use `` when ' ' , when " " in query only
"please add answer mark correct – cardinale 4 mins ago"
after multiple comments:
your fails column's length set low; need increase it.
fails int 1 fails int 10
plus, can use of present queries remove quotes in
where id='3' it's integer
where id=3 edit: added pdo example prepared statements; adjust suit.
<?php $servername = "xxx"; // modify $username = "xxx"; // these $password = "xxx"; // $dbname = "xxx"; // 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 id = :id'; $stmt = $conn->prepare( $query ); $stmt->execute(array(':id' => $userid)); } catch(pdoexception $e) { echo "error: " . $e->getmessage(); } $conn = null;
Comments
Post a Comment