Jump to content
MakeWebGames

Recommended Posts

Posted

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();
?>
Posted (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 by newttster

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...