php - How to debug UPDATE execution in mysqli driver -
i've looked on lot of posts, still can't figure why simple update failing affect database:
$con = mysqli_connect("localhost", "username", "password", "database"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $quantityarray = array(); foreach ($_post $key => $value) { $quantityarray[$key] = $value; } foreach ($quantityarray $key => $value) { $value = mysqli_real_escape_string($con, $value); } foreach ($quantityarray $key => $value) { $query = "update inventory set quantity = $value uniqueid = $key"; echo "<br /><br / >" . $query . "<br /><br / >"; $result = mysqli_query($con, $query); echo "<br /><br / >" . $result . "<br /><br / >"; }
when script called, $_post array of unique ids keys , quantities values (both of integer values). i've tested , confirmed that, yes, appropriate keys , values being passed, why isn't working mystery me.
update: $result returns nothing @ all
thank help!
from comments we've got simple solution: mysqli_error( $con );
helped figure out default user right not enough perform update operations specified table. adding new user appropriate rights solved issue.
Comments
Post a Comment