mikelmao Posted December 30, 2008 Share Posted December 30, 2008 Whats wrong about this? <?php include "connect.php"; if($_SERVER['REQUEST_METHOD'] == 'POST') { mysql_query("UPDATE servers SET `name`='". $_POST['name'] ."' AND `ip`='". $_POST['ip'] ."' AND `port`='". $_POST['port'] ."' AND `desc`='". $_POST['desc'] ."' WHERE id='". $_POST['id'] ."'"); echo "The changes have been made."; } $a = mysql_query("SELECT * FROM servers WHERE id=". $_GET['id'] .""); while($r = mysql_fetch_array($a)) { echo "<form method='post'> <table> <input type='hidden' value='". $_GET['id'] ."' name='id'> <tr> <td>Server Name:</td> <td><input type='text' value='". $r['name'] ."' name='name'></td> </tr> <tr> <td>Server IP:</td><td><input type='text' value='". $r['ip'] ."' name='ip'></td> </tr> <tr> <td>Server Port:</td><td><input type='text' value='". $r['port'] ."' name='port'></td> </tr> <tr> <td>Description:</td><td><textarea rows='8' cols='35' name='desc'>". nl2br($r['desc']) ."</textarea></td> </tr> <tr> <td><input type='submit' value='Submit'></td> </tr> </table> </form>"; } ?> Something is wrong because it updates the Name to 0 Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 30, 2008 Share Posted December 30, 2008 Most likely $_POST['name'] is not being set. Echo it to check. Because it updates it to $_POST['name'] ."' AND `ip`='". $_POST['ip'] ."' AND `port`='". $_POST['port'] ."' AND `desc`='". $_POST['desc'] ."' WHERE id='". $_POST['id'] ."' which is FALSE (or 0) Check the syntax for UPDATE query. http://dev.mysql.com/doc/refman/5.0/en/update.html Quote Link to comment Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 so how do i fix it =/ Quote Link to comment Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 Do i need to sperate each of those updates? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 30, 2008 Share Posted December 30, 2008 By reading how to use UPDATE correctly from the link above. Quote Link to comment Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 i get confused by reading it.. Quote Link to comment Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 NVM Got it.. Thanks Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 30, 2008 Share Posted December 30, 2008 here is another tutorial that might be of more help http://www.tizag.com/mysqlTutorial/mysqlupdate.php Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 30, 2008 Share Posted December 30, 2008 nevermind Got it.. Thanks Share your solution with others Someone else might be having similar problem in future. Quote Link to comment 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.