简体   繁体   中英

Mysqli Update not working properly

$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {

    die("Connection failed: " . mysqli_connect_error());
}

$sql = "UPDATE Cube SET xValue=15 WHERE Index=1";

mysqli_query($conn, $sql);

mysqli_close($conn);

This seems like it should be pretty straight forward, but for some reason, the xValue field won't change, and I get no errors whatsoever. Been trying this for too long.

as u_mulder said, index is a reserved word in mySQL so you got 2 options:

$sql = "UPDATE Cube SET xValue=15 WHERE Cube.Index=1";

or

$sql = "UPDATE Cube SET xValue=15 WHERE `Index`=1";

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