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
PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page will use code to pull information from a database and display it on the page in a formatted way.Code:
Significance of BPM
Hi Experts,
output printing as hexadecmal... XD
Everything works except the calcem call for the totusold and totuprice. The out put shows up as hex. Im not positive but i think i might have to use PBV or PBR?
preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the string, but only if it is accompanied by a letter, not a number. So if a string was found with a number
php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have those files download together. Can I have it download a folder? Or maybe have it create a zip/rar file
How can I uploading Transactional Data from Legacy to New SAP system
Hell Gurus,
what does this mean? +=
is anyone able to explain what this code is saying?i had it written for me awhile back and now that i wanna change it about to make it my own etc i dont really know what each part is doing...
PHP loop
Okay so I have several "articles" stored in a mysql database and am attempting to echo those onto a PHP page.so on index.php I haveCode: <?php article_layout();?> (yes there is
Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below. $.ajax({ type: "POST", url: "AJAXServices.asmx/GetTechInfo", data: '{ "fieldName": ' +
Is there a function ... auto send IP
Is there some function that can be sent to a ddns service that returns the ip address of a ddns forward. I am working on a script that uses a dvr from a home and the owner wants to have the dvr stream