timmah1 Posted February 10, 2008 Share Posted February 10, 2008 here is my form <form name="processed" action"" method="POST"> <input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>"> <input type="hidden" name="update" id="update" value="y"> <input type="hidden" name="status" id="status" value="y"> <input type="submit" name="Submit" value="Mark as processed <?php echo $row['id']; ?>"> </form> Here is the update if($_POST['update']=="y") { $result = mysql_query("UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'") or die(mysql_error()); echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";; } Why won't this update? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/ Share on other sites More sharing options...
tibberous Posted February 10, 2008 Share Posted February 10, 2008 Is the query getting ran? Stick a die("=)") right after the if and see if it runs. Whats your output? Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463173 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 The same output Order updated Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463175 Share on other sites More sharing options...
Barand Posted February 10, 2008 Share Posted February 10, 2008 I put my sql strings into a variable before calling mysql_query. Then when I have problems like this it is easy to look at the query and check it is OK or not. Try if($_POST['update']=="y") { $sql = "UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'"; echo '<pre>', $sql, '</pre>'; $result = mysql_query($sql) or die(mysql_error()); echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";; } Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463179 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 It does the exact same thing. Here is my entire code for this page <?php include "DB_config.php"; //if($_POST['update']=="y") //die("=)") { //$result = mysql_query("UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'") //or die(mysql_error()); //echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";; //} if($_POST['update']=="y") { $sql = "UPDATE `order` SET processed='".$_POST['status']."' where order_number = '".$_POST['order_number']."'"; echo '<pre>', $sql, '</pre>'; $result = mysql_query($sql) or die(mysql_error()); echo "Order updated<br>Please wait...<meta http-equiv=\"refresh\" content=\"1; url=?cid=adminStatus\" />";; } else { $user = "SELECT * FROM `order`"; $result = mysql_query($user); $numberall = mysql_Numrows($result); ?> <h1>Main System Admin</h1> <table width="90%" border="0" cellspacing="0" cellpadding="10"> <tr> <td bgcolor="#801013"><strong><font color="#FFFFFF">All Orders - Status </font></strong></td> </tr> <tr> <td> <table width="100%" border="0"> <tr> <td>Name</td> <td>Address</td> <td>Phone</td> <td>Quantity</td> <td>Status</td> </tr> <?php if ($numberall==0) { echo "<strong>There are no orders</strong>"; } ?> <?php while($row = mysql_fetch_array( $result )){ ?> <tr valign="top"> <td><?php echo $row['f_name']; ?> <?php echo $row['l_name']; ?></td> <td><?php echo $row['address']; ?><br> <?php echo $row['city']; ?>, <?php echo $row['state']; ?><br> <?php echo $row['zip']; ?></td> <td><?php echo $row['phone']; ?></td> <td><?php echo $row['quantity']; ?></td> <td><?php if($row['status']=="n"){ ?> <form name="processed" action"" method="POST"> <input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>"> <input type="hidden" name="update" id="update" value="y"> <input type="hidden" name="status" id="status" value="y"> <input type="submit" name="Submit" value="Mark as processed <?php echo $row['id']; ?>"> </form> <?php } else { ?> <form name="unprocessed" action"" method="POST"> <input type="hidden" name="order_number" id="order_number" value="<?php echo $row['order_number']; ?>"> <input type="hidden" name="update" id="update" value="y"> <input type="hidden" name="status" id="status" value="n"> <input type="submit" name="Submit" value="Mark as un-processed <?php echo $row['order_number']; ?>"> </form> <?php } ?></td> </tr> <?php } ?> </table></td> </tr> </table> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463183 Share on other sites More sharing options...
Barand Posted February 10, 2008 Share Posted February 10, 2008 It does the exact same thing. I didn't expect it not to. It could be useful if we could see the actual query though. What is the ouput from echo '<pre>', $sql, '</pre>'; I can't run and debug your code - I don't have your database. Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463185 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 http://www.cheezyfries.net/BON2/administration.php?cid=adminStatus Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463187 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 oops u: xxxxxxxx p: xxxxxxxx mod edit Don't want those lying around Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463188 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 UPDATE `order` SET processed='n' where order_number = 'cDGNZ145' Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463193 Share on other sites More sharing options...
Barand Posted February 10, 2008 Share Posted February 10, 2008 Hmm, can't see anything wrong there. Variables are getting passed OK and formatting/syntax look fine. I tried your link but couldn't see anywhere to enter those login details, just the homepage. Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463201 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 Sorry, wrong link http://www.cheezyfries.net/BON2/admin.php Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463212 Share on other sites More sharing options...
Barand Posted February 10, 2008 Share Posted February 10, 2008 When you display, you look for $row['status'] = 'n' When you update, you set 'processed' to 'n' Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463216 Share on other sites More sharing options...
timmah1 Posted February 10, 2008 Author Share Posted February 10, 2008 Something so simple. I changed that var earlier, and forget to change THAT one! Thanks Barand. It works now Quote Link to comment https://forums.phpfreaks.com/topic/90333-updating-mysql-problem/#findComment-463220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.