views:

75

answers:

2
$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

A: 

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.

Typeoneerror
A: 

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

Drew