newttster Posted February 26, 2012 Share Posted February 26, 2012 For the life of me, I can not figure out why this is not updating the db. What am I missing? <?php include "globals.php"; $direction=array( 'North' => 'north', 'West' => 'west', 'East' => 'east', 'South' => 'south',); $dir=$direction[$_POST['direction']]; if($dir=="north") { $db->query("UPDATE catacomb SET north=north+1 WHERE userid=$userid"); } elseif($dir=="west") { $db->query("UPDATE catacomb SET east=east-1 WHERE userid=$userid"); } elseif($dir=="east") { $db->query("UPDATE catacomb SET east=east+1 WHERE userid=$userid"); } elseif($dir=="south") { $db->query("UPDATE catacomb SET north=north-1 WHERE userid=$userid"); } echo"<table align='center'> <tr > <td ><th colspan='15'> <a href='catacomb.php?direction=north'>North</a><br /><br /></td></tr> <tr > <td ><th> <a href='catacomb.php?direction=west'>West</a> <th> <th> <th> <th> <th> <th> <th> <th> <th> <th> <th> <th> <th> <a href='catacomb.php?direction=east'>East</a><br /></td></tr> <tr > <td ><th colspan='15'><br /> <a href='catacomb.php?direction=south'>South</a><br /></td></tr></table>"; $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Ben Nash Posted February 26, 2012 Share Posted February 26, 2012 Is everything spelt right in phpmyadmin? Quote Link to comment Share on other sites More sharing options...
newttster Posted February 26, 2012 Author Share Posted February 26, 2012 Is everything spelt right in phpmyadmin? Yes it certainly is. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted February 27, 2012 Share Posted February 27, 2012 Lol. Your using $_POST when you should be using $_GET Quote Link to comment Share on other sites More sharing options...
newttster Posted February 27, 2012 Author Share Posted February 27, 2012 (edited) Thanks blue. I have changed the Post to Get. I had tried this before and neither had worked. What I had to do was take out the array. My next question is once my "direction" gets to the maximum number; How do I turn the link off? Edited February 27, 2012 by newttster 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.