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 Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/ 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 Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726152 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 so how do i fix it =/ Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726157 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? Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726166 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. Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726167 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 i get confused by reading it.. Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726169 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 NVM Got it.. Thanks Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726172 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 Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726173 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. Link to comment https://forums.phpfreaks.com/topic/138869-solved-update/#findComment-726180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.