Saturday, 14 September 2013

Setting a php variable and displaying it on another page

Setting a php variable and displaying it on another page

I am wanting to run this script to update the db and then check if it did
then in fact update and then set a variable saying so and redirect back
the the previous page and echo out wither the successful update or
unsuccessful update on that page. Currently it runs perfectly but will not
echo out the successful or unsuccessful part. What can I do to fix this?
<?php
include_once('../../../_php/connect.php');
$update_e_id = $_POST['error_id'];
//Update unresolved to resolved
mysql_query("UPDATE error SET resolution='resolved' WHERE id=" .
$update_e_id . "
AND resolution='unresolved'");
//Check if it updated
$checkE_update = "SELECT * FROM error WHERE id=" . $update_e_id . " AND
resolution='resolved'";
$results = mysql_query($checkE_update);
$nr = mysql_num_rows($results);
while($row = mysql_fetch_assoc($results)) {
$checkResolution = $row['resolution'];
}
if($checkResolution = 'resolved') {
$successfullyUpdated = "<p>The error is now resolved.</p>";
header("Location: ../lib_errors.php");
} else {
$didnotUpdateError = "<p>The update was unsuccessful.</p>";
header("Location: ../lib_errors.php");
}
?>

No comments:

Post a Comment