Jump to content

Archived

This topic is now archived and is closed to further replies.

ceptic_newb

help php help needed

Recommended Posts

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


[code]
<?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>
[/code]

Share this post


Link to post
Share on other sites
[quote author=hostfreak link=topic=109147.msg439733#msg439733 date=1158973093]
Can you be more specific? Are you getting any errors or what?
[/quote]
well when this shows i dont get errors i jus get most of the places with a blank empty box beside them

Share this post


Link to post
Share on other sites
on all of your mysql functions, you need to attach

[code=php:0]
or die(mysql_error());
[/code]

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

[code=php:0]
$mysql=mysql_query("SELECT * FROM users WHERE username='$username'") or die(mysql_error());
[/code]

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:

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

Share this post


Link to post
Share on other sites

×

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.