Jump to content

dean7

Members
  • Posts

    309
  • Joined

  • Last visited

Posts posted by dean7

  1. Hi all, the other day I posted the same script up but with errors, but today ive removed them errors but some of the scirpt isnt working i blive.

     

    echo"<link href='regstyle.css' rel='stylesheet' type='text/css'><table width='400' border='0' align='center' cellpadding='2' cellspacing='0' class='table' bordercolor='black'><tr><td class='header'><center>Hit The Streets</td></tr>";
    
    echo"<tr><td><center><b>";
    
    	  $country = mysql_query("SELECT location FROM users WHERE username = '$username'") or die (mysql_error());
      
    if ( $racer1 > $timenow ) {
    echo"You Must Wait $timer1 Seconds Before Racing Again"; }
    else {
    if ( $country == 'England' ) {
    echo"<a href='?race=chris'>Chris </a>";
    }
    elseif ( $country == 'Japan' ) {
    echo"<a href='?race=jon'>Jon</a>";
    }
    elseif ( $country == 'Colombia' ) {
    echo"<a href='?race=allen'>Allen</a>";
    }
    elseif ( $country == 'Usa' ) {
    echo"<a href='?race=laura'>Laura</a>";
    }
    elseif ( $country == 'South Africa' ) {
    echo"<a href='?race=ryu'>Ryu</a>";
    }
    elseif ( $country == 'Mexico' ) {
    echo"<a href='?race=jess'>Jessica</a>";
    } }
    echo"</td></tr></b><tr><td><center><b>";
    

     

    That bit of the code wont show the names in the table. It shows the table layout but not the names in the table.

    Its not displaying any errors either.

     

    I carnt accually see nothing wrong with that bit of the script.

    can anyone see why its doing it?

     

    Thanks

  2. Hi all, ive been working on one of my scripts for my website most of today but ive came to an error which im not sure about.

     

    The Error says:

    Catchable fatal error: Object of class stdClass could not be converted to string in /home/www/*****-******.com/hts2.php on line 372

     

    $racelost = mysql_query("SELECT racelost FROM garage WHERE id='$carid'") or die (mysql_error());
    

     

    That is line 372, but I carnt see nothing wrong with it :(.

     

    Can anyone help me here please?

     

    Thanks.

  3. Hi all, im having trouble with my php script. It has an error saying : Notice: Undefined index: race in /home/www/*****-*****.com/hts2.php on line 93.

     

    So im guessing the undefined index is when there is something wrong with the $_GET function?

     

    If it is i couldnt see what was wrong with my script.

     

    if ($_GET['race']){ // Line 93
      $racer = $_GET['race'];
    
    
    
    
      if ( $racer == 'chris' ) {
       $raced  = "Chris";
       $speeds = "20";
       $ra     = "1";
       $nextrace = time()+120;
       $reps      = rand(500,1200);$fuel      = rand(5,12);
    $mns       = rand(200,1500);}
    

     

    Can anyone else see whats wrong with it?

     

    Thanks.

  4. Hi all, i've coded a script for my website but ive got a few error's in the code which i'm not sure how to sort:

     

     

    Notice: Undefined variable: carid in /home/www/**********/hts2.php on line 11

     

    Notice: Undefined variable: fuel in /home/www/*******/hts2.php on line 13

     

    Notice: Trying to get property of non-object in /home/www/*****/hts2.php on line 23

     

    $timenow = time();
    $username = $_SESSION['username'];
    $query=mysql_query("SELECT * FROM garage WHERE id='$carid' LIMIT 1"); // Line 11
    $info = mysql_fetch_object($query);
    $query1=mysql_query("SELECT * FROM garage WHERE fuel='$fuel' LIMIT 2"); // Line 13
    $info2 = mysql_fetch_object($query1);
    
    // -------------------
    
    if($info->fuel < 15){ // Line 23
    

     

    There the bit's of the code i'm having problems with. I've tried de-bugging it but carn't seem to sort it.

     

    Anyone know why I'm getting these error's?

     

    Thanks.

     

     

  5. Have you tried debugging it?  Lol.

     

    Print out the SQL query and put it directly in to MySQL.  See what happens.

     

    Print out a mysql_error() right after each mysql_query() function.

     

    Also, I see you commented a "not sure about" in your source code.  If you're not sure about something, why not look it up in the manual?

     

    Oh, and Google is always your friend: http://www.google.com/search?q=debugging+mysql+php&ie=utf-8&oe=utf-8&aq=t&client=firefox-a&rlz=1R1GGLL_en___US369

    Yeah ive tryed de-bugging it, been trying for ages lol. Rather new to php aswell so that dont help. Yeah were I commented "Not sure about" is part which im not sure if it would work.

  6. $username = $_SESSION['username'];
    $location = $fetch_users_data->location;
    $carin = mysql_query("SELECT carin FROM users WHERE username = '$username'") or die(mysql_error()); // not sure about
    $car1 = mysql_query("SELECT * FROM garage WHERE owner = '$username' AND carin = '$carin'") or die(mysql_error()); // not sure about
    if(!$car = mysql_fetch_object($car1)) {
        die("Could not fetch row data - MySQL Error: ".mysql_error());
    }
    
    -------------------------------------------------------------------
    
    if ($car->speed <= "39"){ // Line 63
    echo ("Your car must be 40mph or faster to win any races.");
    }elseif ($car->speed >= "40"){
    // Code not needed at the mintue
    }

    I done that and it echoed:

     

    Could not fetch row data - MySQL Error:

     

    But dont know why it carnt fetch the data?

  7. Hi all, ive got a problem with this script, well part of it. Its the same script which i needed help with the other day which i manged to sort, but now its came to a bit im not to sure how to fix.

     

    $username = $_SESSION['username'];
    $location = $fetch_users_data->location;
    $carin = mysql_query("SELECT carin FROM users WHERE username = '$username'");// not sure about
    $car1 = mysql_query("SELECT * FROM garage WHERE owner = '$username' AND carin = '$carin'");; // not sure about
    $car = mysql_fetch_object($car1);
    
    -------------------------------------------------------------------
    
    if ($car->speed <= "39"){ // Line 63
    echo ("Your car must be 40mph or faster to win any races.");
    }elseif ($car->speed >= "40"){
    // Code not needed at the mintue
    }
    

     

    Though that little part of the script, its giving me an error which says :

    Notice: Trying to get property of non-object in /home/www/*****/****.php on line 63

     

    Anyone know why it giving me that error?

     

    Thanks for your help.

  8. Hi all, I have a script for my game website witch is just showing a white page. The idea of the code is so the user can race against the computer and win or lose. Ive tryed looking for ways to sort this but I just carnt see why it isnt showing the code.

     

    Heres the code:

    <?php
    session_start();
    include_once ("includes/config.php");
    include_once ("includes/functions.php");
    include_once ("scheck.php");
    
    // Login check
    if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
    header("Location: index.php");
    }else{
    $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE username='".$_SESSION['username']."'"));
    }
    
    // Error Check
    ini_set ('display_errors', 1);
    error_reporting (E_ALL);
    
    // -------------------------------------------------------------------------
    
    $username = $_SESSION['username'];
    $location = $fetch_users_data->location;
    $carin = mysql_query("SELECT carin FROM users WHERE username = '$username'"); // not sure about
    $car1 = mysql_query("SELECT * FROM garage WHERE username = '$username' AND carin = '$carin'"); // not sure about
    $car = mysql_fetch_object($car1);
    
    // The locations...
    $england = England;
    $japan = Japan;
    $colombia = Colombia;
    $usa = Usa;
    $south = South Africa;
    $mexico = Mexico;
    
    // Check if the user has done them lately
    if ($fetch_users_data->lasthts > time()){
    $time = $fetch_users_data->lasthts - time();
    echo ("<table width='30%' class='table' cellpadding='0' cellspacing='0'><tr><td class='header'><center>Sorry...</center></td></tr><tr>You carnt do any more Hit The Streets yet, please wait $time seconds.</td></tr></table>");
    exit();
    }
    
    // If the user is in England...
    if ($fetch_users_data->carin == 0){
    echo ("Please Get In A Car First <br /> <a href='garage.php' target='mainFrame'>Garage</a>");
    }
    elseif ($fetch_users_data->location == $england){
    
    // Name of the racers in England
    $racername = "Ben";
    $racername1 = "Josh";
    $racername2 = "Amy";
    $racername3 = "Jess";
    
    // The random rep
    $minrep = "500";
    $maxrep = "1200";
    $howmuch = rand ($minrep, $maxrep);
    
    // The random money
    $minmoney = "1000";
    $maxmoney = "5000";
    $moneymade = rand ($minmoney, $maxmoney);
    
    // Make sure they can win all races in that country.
    if ($car->speed <= 39){
    echo ("Your car must be 40mph or faster to win any races.");
    elseif ($car->speed >=40){
    
    // what it will look like if they can win all races
    echo ("<table width='40%' cellpadding='0' cellspacing='0' class='table'>
    	<tr>
    		<td class=header><center>HTS In England</center></td>
    	</tr>
    		<td><a href='?racer=$racername&location=$location&race=0' onClick='Well done, you won, $howmuch rep and $moneymade money.'>$racername</a></td>
    		<td><a href='?racer=$racername1&location=$location&race=1' onClick='Well done, you won, $howmuch rep and $moneymade money.'>$racername1</a></td>
    		<td><a href='?racer=$racername2&location=$location&race=2' onClick='Well done, you won, $howmuch rep and $moneymade money.'>$racername2</a></td>
    		<td><a href='?racer=$racername3&location=$location&race=3' onClick='Well done, you won, $howmuch rep and $moneymade money.'>$racername3</a></td>
    	</tr>
    </table>");	
    }
    mysql_query("UPDATE users SET money='money+$moneymade', rep='rep+$howmuch' WHERE username='$username'") or die ("Couldnt update money/rep. <br /> mysql_error()");
    }
    }
    

     

    Some of the things in the code might not work, but im still learning about somethings.

     

    Thanks for your help.

  9. Hi all, I have this piece of code which im using for my website but for a werid reason its saying the table that it selects the information out of doesnt exist when it does.

     

    This is my code:

     

    $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]'"));
    $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 casino WHERE location='$locations[$i]' AND type='Slots'")) or die (mysql_error()); // Line 168
    $rest=mysql_fetch_object(mysql_query("SELECT * FROM rest WHERE location='$locations[$i]'"));
    $casino_rps = mysql_fetch_object(mysql_query("SELECT * FROM casino WHERE location='$locations[$i]' AND type='RPS'")) or die (mysql_error());
    $casino_race = mysql_fetch_object(mysql_query("SELECT * FROM casino WHERE location='$locations[$i]' AND type='Race'")) or die (mysql_error());
    $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]'"))  or die (mysql_error());
    

     

    The error im getting is:

     

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/www/mafia-drift.co.cc/locations.php on line 168

    Table 'deabot96_users.casino' doesn't exist

     

     

    This isnt the full script, if needing to see it all ask :).

    Thanks for your help.

  10. This should work:

     

    $result = mysql_fetch_assoc(mysql_query("SELECT speed FROM garage WHERE id='$car' AND owner='$username'")) OR DIE(mysql_error());
    $speed = $result['speed'];
    mysql_query("UPDATE garage SET speed='$speed+5' WHERE id='$car' AND owner='$username'") OR DIE ("Couldnt add 5mph");
    echo "Car upgraded!";

    I changed that but it made no different :S.

    But ive also found out that everytime i add a new part to the car it adds another +5 at the end.

    So example: Resource id #15+5+5 MPH

  11. Hi all, ive got got this piece of code:

     

    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$next_1-$upgrades[1]-$upgrades[2]-$upgrades[3]-$upgrades[4]-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    $speed = mysql_query("SELECT speed FROM garage WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE garage SET speed='$speed+5' WHERE id='$car' AND owner='$username'") OR DIE ("Couldnt add 5mph");
    echo "Car upgraded!";
    }
    }
    

    But there seems to be a problem with it.

    When i echo the speed out from database it says:  Resource id #15+5 MPH.

    Allthough what I though it should do is update that table but add 5 to the current ammout.

    Anyone know why its inserting : Resource id #15+5 MPH into the database instaid of 5?

     

    Thanks

  12. Hi all, on my website ive got an upgrade shop which allows users to upgrade there car to a certain level or performance.

     

    Allthough on my script it allows them to upgrade there car to any level..

     

    <?php
    session_start();
    include_once "includes/config.php";
    include_once "includes/functions.php";
    
    if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
    header("Location: index.php");
    }else{
    $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE username='".$_SESSION['username']."'"));
    }
    
    $username=$_SESSION['username'];
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
    
    
    
    if (strip_tags($_GET['car'])){
    $car=strip_tags($_GET['car']);
    $check=mysql_query("SELECT * FROM garage WHERE id='$car' AND owner='$username'");
    $true=mysql_num_rows($check);
    $stuff=mysql_fetch_object($check);
    if ($true != "0"){
    $upgrades=explode("-", $stuff->upgrades);
    $next_1=$upgrades[0]+1;
    $next_2=$upgrades[1]+1;
    $next_3=$upgrades[2]+1;
    $next_4=$upgrades[3]+1;
    $next_5=$upgrades[4]+1;
    $next_6=$upgrades[5]+1;
    $next_7=$upgrades[6]+1;
    $next_8=$upgrades[7]+1;
    
    if (strip_tags($_POST['up1'])){
    $price= $next_1*1000;
    
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$next_1-$upgrades[1]-$upgrades[2]-$upgrades[3]-$upgrades[4]-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up2'])){
    $price= $next_1*1000;
    
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$next_2-$upgrades[2]-$upgrades[3]-$upgrades[4]-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up3'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$next_3-$upgrades[3]-$upgrades[4]-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up4'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$upgrades[2]-$next_4-$upgrades[4]-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up5'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$upgrades[2]-$upgrades[3]-$next_5-$upgrades[5]-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up6'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$upgrades[2]-$upgrades[3]-$upgrades[4]-$next_6-$upgrades[6]-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!"; 
    }
    }elseif (strip_tags($_POST['up7'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$upgrades[2]-$upgrades[3]-$upgrades[4]-$upgrades[5]-$next_7-$upgrades[7]";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }
    }elseif (strip_tags($_POST['up8'])){
    $price= $next_1*1000;
    if ($fetch->money < $price){
    echo "You dont have enough money to upgrade your car!";
    }elseif ($fetch->money >= $price){
    $new_money=$fetch->money-$price;
    $new_up="$upgrades[0]-$upgrades[1]-$upgrades[2]-$upgrades[3]-$upgrades[4]-$upgrades[5]-$upgrades[6]-$next_8";
    mysql_query("UPDATE garage SET upgrades='$new_up' WHERE id='$car' AND owner='$username'");
    mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
    echo "Car upgraded!";
    }}
    
    
    
    
    }
    
    }
    
    
    
    ?>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    <body class="body">
    <link rel="stylesheet" href="regstyle.css" type="text/css">
    <form name="form2" method="post" action="">
      <table width="67%" border="1" class="table" class="table" align="center" cellpadding="0" cellspacing="0">
        <tr> 
        <td class="header" colspan="2"><center>Part Shop</center></td>
        </tr>
              <tr> 
                <td width="55%"><div align="center" class="forum">Car:</div></td>
                <td width="45%"> <select name="choose" id="choose" onChange="MM_jumpMenu('this',this,0)">
                    <option selected>Choose car</option>
                    
    <?php $get=mysql_query("SELECT * FROM garage WHERE owner='$username'");
    while($it=mysql_fetch_object($get)){
    
    
    echo "<option value=?car=$it->id>$it->car, $it->damage%</option>";
    }
    ?>
                  </select> </td>
              </tr><?php if (strip_tags($_GET['car'])){
    	  ?>
              <tr> 
                <td><div align="center" class="forum">Tyres</div></td>
                <td width="45%"><div align="center" class="forum">Engine</div></td>
              </tr>
              <tr> 
                <td><div align="center"> 
                    <input name="up1" type="submit" id="up1" value="Upgrade to level <?php echo "$next_1"; ?>">
                  </div></td>
                <td><div align="center"> 
                    <input name="up2" type="submit" id="up2" value="Upgrade to level <?php echo "$next_2"; ?>">
                  </div></td>
              </tr>
              <tr> 
                <td><div align="center" class="forum">Interior</div></td>
                <td><div align="center" class="forum">Exhaust</div></td>
              </tr>
              <tr> 
                <td><div align="center"> 
                    <input name="up3" type="submit" id="up3" value="Upgrade to level <?php echo "$next_3"; ?>">
                  </div></td>
                <td><div align="center"> 
                    <input name="up4" type="submit" id="up4" value="Upgrade to level <?php echo "$next_4"; ?>">
                  </div></td>
              </tr>
              <tr> 
                <td><div align="center" class="forum">NOS</div></td>
                <td><div align="center" class="forum">Rims</div></td>
              </tr>
              <tr> 
                <td><div align="center"> 
                    <input name="up5" type="submit" id="up5" value="Upgrade to level <?php echo "$next_5"; ?>">
                  </div></td>
                <td><div align="center"> 
                    <input name="up6" type="submit" id="up6" value="Upgrade to level <?php echo "$next_6"; ?>">
                  </div></td>
              </tr>
              <tr> 
                <td><div align="center" class="forum">Brakes</div></td>
                <td><div align="center" class="forum">Body kit</div></td>
              </tr>
              <tr> 
                <td><div align="center"> 
                    <input name="up7" type="submit" id="up7" value="Upgrade to level <?php echo "$next_7"; ?>">
                  </div></td>
                <td><div align="center"> 
                    <input name="up8" type="submit" id="up8" value="Upgrade to level <?php echo "$next_8"; ?>">
                  </div></td>
              </tr>
    <? } ?>
            </table>
    </form>
    <p align="center">
      <?php include_once"includes/footer.php"; ?>
    

     

    Anyone know how I can make it so only allows you to upgrade your car to level 40?

     

    Thanks

×
×
  • Create New...

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.