contra10 Posted January 26, 2009 Share Posted January 26, 2009 i cant seem to update a value <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['eid'])){ $id = $_GET['eid']; } if (isset($_POST['true'])){ mysql_query("UPDATE events SET value = 'true' WHERE eid = '$id'"); } if (isset($_POST['false'])){ mysql_query("UPDATE events SET value = 'false' WHERE eid = '$id'"); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > <input type="submit" name ="true" value="Yes"> <input type="submit" name ="false" value="No"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/ Share on other sites More sharing options...
Maq Posted January 26, 2009 Share Posted January 26, 2009 Do this for both your queries and see if there are any errors or if your queries are even correct. $sql = "UPDATE events SET value = 'true' WHERE eid = '$id'"; echo $sql mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/#findComment-746757 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 you're not sending eid with the form Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/#findComment-746759 Share on other sites More sharing options...
kenrbnsn Posted January 26, 2009 Share Posted January 26, 2009 I don't see where you're putting the "eid" on the URL, so you're probably not getting it. Are you getting any errors? Try this: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); $tf = array('Yes' => 'true', 'No' => 'false'); if (!isset($_GET['eid'])) { echo "Id not set, can't continue<br>\n"; } else { $id = $_GET['eid']; $val = $tf[$_POST['submit']]; $q = "update events set value = '" . $val . "' where eid = '$id'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > <input type="submit" name ="submit" value="Yes"> <input type="submit" name ="submit" value="No"> </form> Ken Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/#findComment-746762 Share on other sites More sharing options...
contra10 Posted January 26, 2009 Author Share Posted January 26, 2009 ye...id wasn't sent ....but when i click onto this page the id is set in the url... Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/#findComment-746769 Share on other sites More sharing options...
contra10 Posted January 26, 2009 Author Share Posted January 26, 2009 this is what i tried...i get my "query was empty" <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['eid'])){ $id = $_GET['eid']; } $idp = mysql_real_escape_string($_POST['idev']); if (isset($_POST['true'])){ mysql_query("UPDATE events SET value = 'true' WHERE eid = '$idp'"); mysql_query($sql) or die(mysql_error()); // Create the URL string $url = "http://localhost/events/createvisible.php?eid=$id"; // Final Echo the meta tag echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">'); } if (isset($_POST['false'])){ mysql_query("UPDATE events SET value = 'false' WHERE eid = '$idp'"); mysql_query($sql) or die(mysql_error()); // Create the URL string $url = "http://localhost/events/createvisible.php?eid=$idp"; // Final Echo the meta tag echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">'); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > <input type="submit" name ="true" value="Yes"> <?php echo "<input type='hidden' name='idev' value='$id'>"?> <input type="submit" name ="false" value="No"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/142508-solved-cant-input-into-mysql-update/#findComment-746777 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.