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
Basic Question about Threading and PHP...
I have a page that I am working on and it is taking several hours to process. The basics of what the page does is get all the items out of a database then with cURL download some HTML parse through
Auto install
Hi I have a directory lets say "apps" that I then have more folders ie "email", "projectmanagment" now each of these "apps" need a mysql table, each of these
Simple email form - Newbie
Hello all,First time poster!I've been asked to create a simple HTML form that submits and sends the information to a particular email.The client is using PHP. Since I have a .NET and C# background,
adding up might be solved tell us cheers.
i think i finally solved this anybody.last time i was getting the wrong results.Code: <?php// price of item.$price="100.00";//quenity of items.$quenity="7";// tax
List/Menu Box
On an edit page when you want something to select what a user has previously selected from the database, how would you do this for a List/Menu box? The only way I know how is Code: <?php echo
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?in PHP of course.i don't know if i'm really that dumb or is it the 36 hours of no sleep that i can't
How to change Time Zone
HII want to change the time zone of the server to another country.How can do that?Thanks
max() problem
I have a while loop to get image names. Code: $imagequery = mysql_query("SELECT * FROM ad_image WHERE user='$user' AND ad='$adnr' ORDER BY `picorder` ASC")or die(mysql_error());$totpics =
How to pass parameter to tag query?
Hi,
file downloaded can't be read !!
<?php $fileName = 'mypic.jpg';$mimeType = 'image/jpeg';header('content-disposition: attachment; filename=' . $fileName);header('content-type: ' . $mimeType);header('content-length: ' .