Jump to content


Photo

help php help needed


  • Please log in to reply
4 replies to this topic

#1 ceptic_newb

ceptic_newb
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 September 2006 - 12:56 AM

help i cant get this to work ive tryed my best  ??? :(


<?php
session_start(); 
include_once "includes/db_connect.php";
include_once "includes/functions.php";

$username=$_SESSION['username'];
$mysql=mysql_query("SELECT * FROM users WHERE username='$username'");
$fetch=mysql_fetch_object($mysql);

$username=$_SESSION['username'];
$grab = strip_tags($_GET['grab']);
$location=strip_tags($_GET['location']);

if (($grab == "Ammo") || ($grab == "Airport") || ($grab == "Bank") || ($grab == "Casinos") || ($grab == "Dealership") || ($grab == "Restu")|| ($grab == "Bar")|| ($grab == "Shop")){


if ($grab == "Ammo"){

$check = mysql_query("SELECT * FROM bf WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE bf SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the Ammo hut!";
}}}

elseif ($grab == "Airport"){

$check = mysql_query("SELECT * FROM airport WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE airport SET owner='$username', profit='0-0-0-0-0-0' WHERE location='$fetch->location'");
echo "You got the Airport!";
}}}

elseif ($grab == "Bank"){

$check = mysql_query("SELECT * FROM bank WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE bank SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the bank!";
}}}
elseif ($grab == "Shop"){

$check = mysql_query("SELECT * FROM shop WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE shop SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the shop!";
}}}

////START CASINOS


elseif ($grab == "Casinos"){
$the_get=$_GET['casino'];

if ($the_get == "Slots" || $the_get == "Blackjack" || $the_get=="Race" || $the_get=="Keno" || $the_get=="Roulette" || $the_get=="Roulette"){

$check = mysql_query("SELECT * FROM casinos WHERE owner= '0' AND location='$fetch->location' AND casino='$the_get'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE casinos SET owner='$username', profit='0' WHERE location='$fetch->location' AND casino='$the_get'");
echo "You got the casino!";
}}}}






//////END CASINOS

elseif ($grab == "Dealership"){
$check = mysql_query("SELECT * FROM dealership WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE dealership SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the dealership!";
}}}


elseif ($grab == "Restu"){

$check = mysql_query("SELECT * FROM rest WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE rest SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the Restaurant!";
}}}

elseif ($grab == "Bar"){
$check = mysql_query("SELECT * FROM bar WHERE owner= '0' AND location='$fetch->location'");
$num_rows = mysql_num_rows($check);

if ($num_rows != "0"){

if ($fetch->location == $location){

mysql_query("UPDATE bar SET owner='$username', profit='0' WHERE location='$fetch->location'");
echo "You got the Bar!";
}}


}


}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<table width="100%" border="0" cellpadding="0" cellspacing="3" height="514">
  <!--DWLayoutTable-->
   
  <?php 
  
$locations = array('England', 'Japan', 'Colombia', 'Usa', 'South Africa', 'Mexico');
$i =0;
$count = count($locations);
while ($i < $count){
if ($i == "2"){ echo "<tr>"; }
$airport = mysql_fetch_object(mysql_query("SELECT * FROM airport WHERE location='$locations[$i]'"));
$ammo_hut = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$locations[$i]'"));
$bank = mysql_fetch_object(mysql_query("SELECT * FROM bank WHERE location='$locations[$i]'"));
$people_in = mysql_num_rows(mysql_query("SELECT * FROM users WHERE location='$locations[$i]'"));
////$resturant = mysql_fetch_object(mysql_query("SELECT * FROM restur WHERE location='$locations[$i]'"));
$dealer=mysql_fetch_object(mysql_query("SELECT * FROM dealership WHERE location='$locations[$i]'"));
$rest=mysql_fetch_object(mysql_query("SELECT * FROM rest WHERE location='$locations[$i]'"));
$casino_slots = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE location='$locations[$i]' AND casino='Slots'"));
$rest=mysql_fetch_object(mysql_query("SELECT * FROM rest WHERE location='$locations[$i]'"));
$casino_bj = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE location='$locations[$i]' AND casino='Blackjack'"));
$casino_race = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE location='$locations[$i]' AND casino='Race'"));
$casino_Roulette = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE location='$locations[$i]' AND casino='Roulette'"));
$casino_keno = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE location='$locations[$i]' AND casino='Keno'"));
$bar = mysql_fetch_object(mysql_query("SELECT * FROM bar WHERE location='$locations[$i]'"));
$shop = mysql_fetch_object(mysql_query("SELECT * FROM shop WHERE location='$locations[$i]'"));

  ?>
    <td height="275" >
	<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="black" class=thinline height="250">
        <!--DWLayoutTable-->
        <tr > 
          <td background="includes/grad.jpg" colspan="3" valign="top" height="1"> <div align="center"><?php echo "<center>$locations[$i]</center>"; ?></div></td>
        </tr>
        <tr bgcolor=white> 
          <td width="304" height="5" valign="top" class=tip><div align="center">Buisness</div></td>
          <td width="184" class=tip height="5"><div align="center">Owner </div></td>
          <td width="233" class=tip height="5"><div align="center">Max bet </div></td>
        </tr>
        <tr> 
          <td height="20" valign="top">Airport</td>
          <td width="184" height="20"> 
            <?php if ($airport->owner == "0"){ echo "No owner-<a href='?grab=Airport&location=$locations[$i]'>Grab it></a>"; }else{ echo "<a href='profile.php?viewuser=$airport->owner'>$airport->owner</a>"; } ?>
          </td>
          <td width="233" height="20"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
        <tr> 
          <td height="20" valign="top">Bank</td>
          <td width="184" height="20"> 
            <?php if ($bank->owner == "0"){ echo "No owner-<a href='?grab=Bank&location=$locations[$i]'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$bank->owner'>$bank->owner</a>";  } ?>
          </td>
          <td width="233" height="20"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
        
        <tr> 
          <td height="20" valign="top">Dealership</td>
          <td width="184" height="20"> 
            <?php if ($dealer->owner == "0"){ echo "No owner-<a href='?grab=Dealership&location=$locations[$i]'>Grab it</a></td>"; }else{ echo "<a href='profile.php?viewuser=$dealer->owner'>$dealer->owner</a>";} ?>
          </td>
          <td width="233" height="20"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
        <tr> 
          <td height="20" valign="top">Slots</td>
          <td width="184" height="20"> 
            <?php if ($casino_slots->owner == "0"){ echo "No owner-<a href='?grab=Casinos&location=$locations[$i]&casino=Slots'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$casino_slots->owner'>$casino_slots->owner</a>";  } ?>
          </td>
          <td width="233" height="20"><? echo "£".makecomma($casino_slots->max).""; ?></td>
        </tr>
        <tr> 
          <td height="20" valign="top">Race track</td>
          <td width="184" height="20"> 
            <?php if ($casino_race->owner == "0"){ echo "No owner-<a href='?grab=Casinos&location=$locations[$i]&casino=Race'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$casino_race->owner'>$casino_race->owner</a>";  } ?>
          </td>
          <td width="233" height="20"> <? echo "£".makecomma($casino_race->max).""; ?></td>
        </tr>
	
		   <tr> 
          <td height="20" valign="top">Keno</td>
          <td width="184" height="20"> 
            <?php if ($casino_keno->owner == "0"){ echo "No owner-<a href='?grab=Casinos&location=$locations[$i]&casino=Keno'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$casino_keno->owner'>$casino_keno->owner</a>";  } ?>
          </td>
          <td width="233" height="20"> <? echo "£".makecomma($casino_keno->max).""; ?></td>
        </tr>
 <tr> 
          <td height="20" valign="top">Roulette</td>
          <td width="184" height="20"> 
            <?php if ($casino_Roulette->owner == "0"){ echo "No owner-<a href='?grab=Casinos&location=$locations[$i]&casino=Roulette'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$casino_Roulette->owner'>$casino_Roulette->owner</a>";  } ?>
          </td>
          <td width="233" height="20"> <? echo "£".makecomma($casino_Roulette->max).""; ?></td>
        </tr>
<tr> 
          <td height="20" valign="top">Blackjack</td>
          <td width="184" height="20"> 
            <?php if ($casino_bj->owner == "0"){ echo "No owner-<a href='?grab=Casinos&location=$locations[$i]&casino=bj'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$casino_bj->owner'>$casino_bj->owner</a>";  } ?>
          </td>
          <td width="233" height="20"> <? echo "£".makecomma($casino_bj->max).""; ?></td>
        </tr>

        <tr> 
          <td width="304" height="20" valign="top">Underground</td>
          <td width="184" height="20"> 
            <?php if ($shop->owner == "0"){ echo "No owner-<a href='?grab=Shop&location=$locations[$i]'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$shop->owner'>$shop->owner</a>";  } ?>
          </td>
          <td width="233" height="20"><!--DWLayoutEmptyCell--></td>
        </tr>
        <tr> 
          <td height="20" valign="top">Ammo hut</td>
          <td height="20"><?php if ($ammo_hut->owner == "0"){ echo "No owner-<a href='?grab=Ammo&location=$locations[$i]'>Grab it</a>"; }else{ echo "<a href='profile.php?viewuser=$ammo_hut->owner'>$ammo_hut->owner</a>"; } ?></td>
          <td height="20">&nbsp;</td>
        </tr>
      </table></td>
	  
	  <?php 
	 if ($i == "3"){ echo "</tr>"; } 
	  
	  $i++; } ?>

</table>
</body>
</html>


#2 ceptic_newb

ceptic_newb
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 September 2006 - 12:57 AM

i cant get some of the things to work i can only get the ammo hut and the airport to work

#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 23 September 2006 - 12:58 AM

Can you be more specific? Are you getting any errors or what?

#4 ceptic_newb

ceptic_newb
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 September 2006 - 12:59 AM

Can you be more specific? Are you getting any errors or what?

well when this shows i dont get errors i jus get most of the places with a blank empty box beside them

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 23 September 2006 - 01:42 AM

on all of your mysql functions, you need to attach

or die(mysql_error()); 

to the end of it. it may give you a helpful clue as to what is wrong. example:

$mysql=mysql_query("SELECT * FROM users WHERE username='$username'") or die(mysql_error());

also, it helps to seperate the query string from the query function, for debugging.  That way, you can echo out what is actually being queried. For instance, perhaps you are connecting just fine, but your variables used in the query are not holding what they should be holding. example:

$sql = "SELECT * FROM users WHERE username='$username'";
echo "query string: $sql <br>";
$mysql = mysql_query($sql) or die(mysql_error());

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users