简体   繁体   中英

Updating integer field in a row by 1 using php and mysqli

I want to find the row where the username, password, email country etc. matches and update "points" in that row by 1 point. Why isn't my code working?

<?php

$con=mysqli_connect("mysql_host","mysql_user","mysql_password","mysql_database");

$country = $_POST["country"];
$district = $_POST["district"];
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];



$query = "UPDATE table SET points=points+1 WHERE country = ? AND district = ? username = ? AND email = ? AND password = ?";
$statement = mysqli_prepare($con, $query);
mysqli_stmt_bind_param($statement, "isssss", $points, $country, $district, $username, $email, $password);
mysqli_stmt_execute($statement);
mysqli_close($con);

try to change,

$query = "UPDATE table SET points=points+1 WHERE country = ? AND district = ? username = ? AND email = ? AND password = ?";

to

$query = "UPDATE table SET points=points+1 WHERE country = ? AND district = ? AND username = ? AND email = ? AND password = ?";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM