elseif help!


Posted on 16th Feb 2014 07:03 pm by admin

OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and so far it's been quite smooth. However whilst trying to change an aspect of the game from giving the user the location of another user into giving the user the continent another user is in I have become a bit stuck. Here is the original piece of code:

if ($action=="choose")
{
$infoskill=$currentuser["infoskill"];
$infoskill=$infoskill+makeBonus($user,"i",$db);
if ($find=="location")
{
if ($infoskill > 14)
{
$cost=round((15/$infoskill)*300);
if ($cost <20)
{
$cost=20;
}
if ($currentuser["cash"]<$cost)
{
echo " You can't afford that information.
n";
}
else
{
$sql="SELECT * FROM `users` WHERE `name` = '$usertofind' AND `dead` = 'n'";
$userlocationresult = runSQL($sql, $currentuser["admin"]);
if ($userlocation = mysql_fetch_array($userlocationresult))
{
echo " $usertofind is in ".$userlocation["location"].".
n";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
else
{
echo " The user you entered doesn't exist or is dead.
n";
}
}
}
else
{
echo " You don't have the contacts to find that information.
n";
}
}
elseif ($find=="skills")
{
if ($infoskill > 19)
{
$cost=round((20/$infoskill)*400);
if ($cost <20)
{
$cost=20;
}
if ($currentuser["cash"]<$cost)
{
echo " You can't afford that information.
n";

As you can see in the middle of that piece the user can pay to see the location of another user, providing the target is not dead and the user has enough cash. Now instead of giving the exact location of the target I am trying to group the cities into continents, like so:

if ($action=="choose")
{
$infoskill=$currentuser["infoskill"];
$infoskill=$infoskill+makeBonus($user,"i",$db);
if ($find=="location")
{
if ($infoskill > 14)
{
$cost=round((15/$infoskill)*300);
if ($cost <20)
{
$cost=20;
}
if ($currentuser["cash"]<$cost)
{
echo " You can't afford that information.
n";
}
else
{
$sql="SELECT * FROM `users` WHERE `name` = '$usertofind' AND `dead` = 'n'";
$userlocationresult = runSQL($sql, $currentuser["admin"]);
if ($userlocation = London || Milan || Paris || Dublin || Moscow)
{
echo " $usertofind is in Europe.";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
elseif ($userlocation = Lagos || Johannesburg || Nairobi)
{
echo " $usertofind is in Africa";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
elseif ($userlocation = New York || Los Angeles || Dallas)
{
echo " $usertofind is in North America";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
elseif ($userlocation = Bogota || Rio De Janeiro || Buenos Aires)
{
echo " $usertofind is in South America";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
elseif ($userlocation = Mexico City || Havana || Kingston)
{
echo " $usertofind is in Central America";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
else
{
echo " $usertofind is in Asia";
runSQL("UPDATE `users` SET `cash`=`cash`-'$cost' WHERE `name`='$user'", $currentuser["admin"]);
}
}
}
else
{
echo " You don't have the contacts to find that information.
n";
}
}
elseif ($find=="skills")
{
if ($infoskill > 19)
{
$cost=round((20/$infoskill)*400);
if ($cost <20)
{
$cost=20;
}
if ($currentuser["cash"]<$cost)
{
echo " You can't afford that information.
n"

This however gives the following error message:

Parse error: syntax error, unexpected T_STRING in /home/a7098669/public_html/getinfo.php on line 158

What can I do to solve this? And instead of giving just text answers could I group the locations into continents and just have one response which would be something like:

"$usertofind is in $continent"

I hope someone can help!

Thanks

No comments posted yet

Your Answer:

Login to answer
148 Like 17 Dislike
Previous forums Next forums
Other forums

FlashVar function how to insert variables
Hi guys. Im new in this forum and also new in php programming. Can you help me about this code?
<

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an

Changing color in GD via variable?
Hey guys, I'm new here. x)

I'm very much a noob when it comes to PHP, but I'm trying to learn

Problem with a select distinct
I have a problema with a select distinct, I have the next sql:

select distinct a,b,c,d fr

moving mouse to display image coordinates
I have an existing MFC application that shows an image in the main window.
I'd like to be able to

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

Log $_POST
How would i log submits on a form, by everyone? I want to then echo the number of submissions.

Shopping Cart
Can anyone direct me to a Simple, Basic structure of a shopping cart.
New to classes. I want to s

Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash