Jump to content

variable vanishing?


almightyegg

Recommended Posts

I was writing this script and I thought I'd test just this first bit and it isn't working...

 

if(!$move){
$x = 1;
$y = 1;
echo "Current Position: $x,$y<br />";
echo "<center><a href='pit.php?move=n'>[North]</a><br>
<a href='pit.php?move=w'>[West]</a> <a href='pit.php?move=e'>[East]</a><br>
<a href='pit.php?move=s'>[south]</a></center>";
}elseif($move == s){
$y = $y+1;
echo "Current Position: $x,$y<br />";
echo "<center><a href='pit.php?move=n'>[North]</a><br>
<a href='pit.php?move=w'>[West]</a> <a href='pit.php?move=e'>[East]</a><br>
<a href='pit.php?move=s'>[south]</a></center>";
}elseif($move == n){
$y = $y-1;
echo "Current Position: $x,$y<br />";
echo "<center><a href='pit.php?move=n'>[North]</a><br>
<a href='pit.php?move=w'>[West]</a> <a href='pit.php?move=e'>[East]</a><br>
<a href='pit.php?move=s'>[south]</a></center>";
}elseif($move == e){
$x = $x+1;
echo "Current Position: $x,$y<br />";
echo "<center><a href='pit.php?move=n'>[North]</a><br>
<a href='pit.php?move=w'>[West]</a> <a href='pit.php?move=e'>[East]</a><br>
<a href='pit.php?move=s'>[south]</a></center>";
}elseif($move == w){
$x = $x-1;
echo "Current Position: $x,$y<br />";
echo "<center><a href='pit.php?move=n'>[North]</a><br>
<a href='pit.php?move=w'>[West]</a> <a href='pit.php?move=e'>[East]</a><br>
<a href='pit.php?move=s'>[south]</a></center>";
}

 

It isn't finding $x and $y properly. If it $move = e or w then it says "Current Position: ,1" and if it is n or s it says "Current Position: 1," and that 1 never changes...never goes up or down...no matter how many pages it goes...

 

Any idea?

Link to comment
Share on other sites

Right, I've solved that problem thanks for the help guys.

 

Now I have another problem.

 

There are variables like:

$p1d1 = blah;

$p2d1 = blah;

$p3d1 = blah;

etc..

$p1d2 = blah;

$p2d2 = blah;

$p3d2 = blah;

etc..

$p1d3 = blah;

$p2d3 = blah;

$p3d3 = blah;

etc..

 

The first number in each is represented by $x and the second by $y. So when I call the variable I am calling $p$xd$y - of course that doesn't work. What can I do to make it show, in this case, $p1d1???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.