slaterino Posted January 5, 2010 Share Posted January 5, 2010 Does anyone know what is wrong with this code. I am getting no errors or anything, the page is simply refreshing without updating anything. error_reporting(E_ALL); ini_set("display_errors", 1); include ('../library/config.php'); include ('../library/opendb.php'); $id = $_GET['id']; if(isset($_POST['submit'])) { $postage_id = addslashes($_POST['postage_id']); $country = addslashes($_POST['country']); $band = addslashes($_POST['band']); $start = addslashes($_POST['start']); $end = addslashes($_POST['end']); $postage = addslashes($_POST['postage']); $postage_result = mysql_query("UPDATE postage SET country='$country', band='$band', start='$start', end='$end', postage='$postage' WHERE id='$postage_id' " ,$conn) or die('Error, query failed'); header("location: status.php?id=1"); } elseif($id) { <?php } $postage_result = mysql_query("SELECT * FROM postage",$conn); while($myrow = mysql_fetch_assoc($postage_result)) { $postage_id = $myrow['id']; $country = $myrow['country']; $band = $myrow['band']; $start = $myrow['start']; $end = $myrow['end']; $postage = $myrow['postage']; ?> <?php echo "<tr><td><input name='postage_id' type='hidden' value='".$postage_id."'></input></td>"; echo "<td><input name='country' type='text' value='".$country."' size='50'></input></td><td><input name='band' type='text' value='".$band . "' size='2'></input></td><td><input name='start' type='text' value='".$start . "' size='2'></input></td><td><input type='text' name='end' value='".$end . "' size='2'></input></td><td><input name='postage' type='text' value='".$postage . "' size='3'></input></td></tr>"; } } ?> I've checked over everything so many times but can't seem to find the problem!!! Link to comment https://forums.phpfreaks.com/topic/187287-update-query-doing-nothing/ Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Share Posted January 5, 2010 $postage_result = mysql_query("UPDATE postage SET country='$country', band='$band', start='$start', end='$end', postage='$postage' WHERE id='$postage_id' " ,$conn) What's $conn ? according to the code you posted $conn isn't set. Link to comment https://forums.phpfreaks.com/topic/187287-update-query-doing-nothing/#findComment-989026 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2010 Share Posted January 5, 2010 The form in the code you posted is incomplete and cannot work. It would take seeing the whole actual code of your page that does not work in order to be able to help you with why your page is not working. Link to comment https://forums.phpfreaks.com/topic/187287-update-query-doing-nothing/#findComment-989028 Share on other sites More sharing options...
slaterino Posted January 5, 2010 Author Share Posted January 5, 2010 Okay, so I made a few mistakes in copying my code down, but only minor things. This is how it should look: <?php error_reporting(E_ALL); ini_set("display_errors", 1); include ('../library/config.php'); include ('../library/opendb.php'); $id = $_GET['id']; if(isset($_POST['submit'])) { $postage_id = addslashes($_POST['postage_id']); $country = addslashes($_POST['country']); $band = addslashes($_POST['band']); $start = addslashes($_POST['start']); $end = addslashes($_POST['end']); $postage = addslashes($_POST['postage']); $postage_result = mysql_query("UPDATE postage SET country='$country', band='$band', start='$start', end='$end', postage='$postage' WHERE id='$postage_id' " ,$conn) or die('Error, query failed'); header("location: status.php?id=1"); } elseif($id) { $postage_result = mysql_query("SELECT * FROM postage",$conn); while($myrow = mysql_fetch_assoc($postage_result)) { $postage_id = $myrow['id']; $country = $myrow['country']; $band = $myrow['band']; $start = $myrow['start']; $end = $myrow['end']; $postage = $myrow['postage']; ?> <?php echo "<tr><td><input name='postage_id' type='hidden' value='".$postage_id."'></input></td>"; echo "<td><input name='country' type='text' value='".$country."' size='50'></input></td><td><input name='band' type='text' value='".$band . "' size='2'></input></td><td><input name='start' type='text' value='".$start . "' size='2'></input></td><td><input type='text' name='end' value='".$end . "' size='2'></input></td><td><input name='postage' type='text' value='".$postage . "' size='3'></input></td></tr>"; } } ?> There was a rogue open bracket and php tag in there, but have corrected this now. Is there anything wrong with this code???? Link to comment https://forums.phpfreaks.com/topic/187287-update-query-doing-nothing/#findComment-989207 Share on other sites More sharing options...
monkeypaw201 Posted January 5, 2010 Share Posted January 5, 2010 Try and put ` around mysql names, the `id` field may be throwing it off.. Let me/us know what happens. Link to comment https://forums.phpfreaks.com/topic/187287-update-query-doing-nothing/#findComment-989240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.