Paws Posted August 2, 2009 Share Posted August 2, 2009 <form method="post" action="adminprocess.php"> <label>Board Name <input type="text" name="forumname" value="<?php echo $info_r['forum_name']; ?>"> </label> <p> <label>Board Description <input type="text" name="forumdescription" value="<?php echo $info_r['forum_description']; ?>"> </label> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> $forumname = $_GET['forumname']; $forumdescription = $_GET['forumdescription']; $query = "UPDATE `info` SET `forum_name` = '$forumname' AND `info`.`forum_description` = '$forumdescription'"; mysql_query($query); I'm using that code to update my database but it isn't working :/ Can anyone help? Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/ Share on other sites More sharing options...
Bricktop Posted August 2, 2009 Share Posted August 2, 2009 Try: $forumname = $_POST['forumname']; $forumdescription = $_POST['forumdescription']; $query = "UPDATE `info` SET `forum_name` = '$forumname' AND `info`.`forum_description` = '$forumdescription'"; mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888793 Share on other sites More sharing options...
phpSensei Posted August 2, 2009 Share Posted August 2, 2009 ^^ EXPLAIN TO HIM WHAT HE DID WRONG! <form method="post" Your form method is post, thus you must get the HTTP POST VARS using $_POST....instead you were using $_GET Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888795 Share on other sites More sharing options...
Paws Posted August 2, 2009 Author Share Posted August 2, 2009 ^^ EXPLAIN TO HIM WHAT HE DID WRONG! <form method="post" Your form method is post, thus you must get the HTTP POST VARS using $_POST....instead you were using $_GET Thanks, god I feel like an idiot now -.- Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888797 Share on other sites More sharing options...
phpSensei Posted August 2, 2009 Share Posted August 2, 2009 ^^ EXPLAIN TO HIM WHAT HE DID WRONG! <form method="post" Your form method is post, thus you must get the HTTP POST VARS using $_POST....instead you were using $_GET Thanks, god I feel like an idiot now -.- Don't worry lol, we all make mistakes, and thank Bricktop for fixing it for ya. Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888801 Share on other sites More sharing options...
Paws Posted August 2, 2009 Author Share Posted August 2, 2009 Ok, i've got a different problem now, when ever the user submits the forum it always puts the value as 0 in the database? :/ Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888847 Share on other sites More sharing options...
phpSensei Posted August 2, 2009 Share Posted August 2, 2009 Ok, i've got a different problem now, when ever the user submits the forum it always puts the value as 0 in the database? :/ whats the column data type? Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888861 Share on other sites More sharing options...
Paws Posted August 2, 2009 Author Share Posted August 2, 2009 Text Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888912 Share on other sites More sharing options...
Paws Posted August 2, 2009 Author Share Posted August 2, 2009 Bump Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-888948 Share on other sites More sharing options...
Paws Posted August 3, 2009 Author Share Posted August 3, 2009 Bump Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889421 Share on other sites More sharing options...
gevans Posted August 3, 2009 Share Posted August 3, 2009 Before you do the mysq_query() output the query variable to see if it's what you expect it to be; $forumname = $_POST['forumname']; $forumdescription = $_POST['forumdescription']; $query = "UPDATE `info` SET `forum_name` = '$forumname' AND `info`.`forum_description` = '$forumdescription'"; echo $query; mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889425 Share on other sites More sharing options...
Paws Posted August 3, 2009 Author Share Posted August 3, 2009 Yeah, its what it should be Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889444 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 Yeah, its what it should be mysql_query($query); that should be in a variable. You are echoing the mysql query, it has to be printed out using mysql_fetch_array, or mysql_fetch_assoc or mysql_fetch_object....or...etc Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889446 Share on other sites More sharing options...
gevans Posted August 3, 2009 Share Posted August 3, 2009 Yeah, its what it should be Can you post it, it's hard to help when you don't show what you're getting. Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889448 Share on other sites More sharing options...
Paws Posted August 3, 2009 Author Share Posted August 3, 2009 UPDATE `info` SET `forum_name` = 'forum' AND `info`.`forum_description` = 'description' Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889451 Share on other sites More sharing options...
gevans Posted August 3, 2009 Share Posted August 3, 2009 If you're doing an update you need a WHERE clause so you know what one you're updating. Otherwise it will try and update the whole table. Link to comment https://forums.phpfreaks.com/topic/168485-help-updating-database/#findComment-889452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.