开发者

Problems with my prepared statement update

开发者 https://www.devze.com 2022-12-11 10:33 出处:网络
$query = \"UPDATE kids_entry SET entries=? WHERE parentsemail=?\"; $stmt1 = mysqli_prepare($connection, $query);
$query = "UPDATE kids_entry SET entries=? WHERE parentsemail=?";
$stmt1 = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt1, 'is',$entries,$parentsemail);
mysqli_execute($stmt1);
if(mysqli_stmt_affected_rows($stmt1) != 1)
    die("issueasdass"); 
mysqli_stmt_close($stmt1);

The above code does work for me on another page but i cannot seem to get it to work here. On the other page the set to update is a hardcoded in and 开发者_运维技巧is not dynamic so that might be why it isn't working for me. Can someone tell me what I am doing wrong? Thanks


Is it possible that entries is the same value as what's already in the database? I don't think *_affected_rows returns 1 if nothing changes. Is it possible that there's more than 1 entry for 'parentsemail'? So perhaps mysqli_stmt_affected_rows is returning something like 2? Instead of checking 1, maybe let us know what mysql_stmt_affected_rows is returning. For example, from the docs:

An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records where updated for an UPDATE/DELETE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query has returned an error.


The issue appears to have resolved itself. Nothing has changed but now it works!

0

精彩评论

暂无评论...
验证码 换一张
取 消