Jump to content

Recommended Posts

hi im getting this error and i have never seen this error b4  :-\

 

Just Need Help Sorting It

 

Catchable fatal error: Object of class stdClass could not be converted to string in /home/mafiamur/public_html/arm.php on line 112

 

 

 

<?
session_start();
include "includes/functions.php";
logincheck();
$username=$_SESSION['username'];
include "includes/db_connect.php";
$date = gmdate('Y-m-d h:i:s');
$page="arm.php";

echo "$style";
echo " <form method=post action=''>";
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$info=mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$username'"));
$stats=explode(":",$info->wl);

if ($info->mem_gym == "0"){
if (strip_tags($_GET['member']) == "yes"){
if ($fetch->money < "1000"){
echo "You dont have enough money!";
}elseif ($fetch->money >= "1000"){
$new_money=$fetch->money - 1000;
mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
mysql_query("UPDATE user_info SET mem_gym='1' WHERE username='$username'");
echo "Membership purchased <a href=arm.php>Click here to continue</a>";
}}

?>
<table width="74%" border="1" align="center" cellpadding="2" cellspacing="0" class=thinline bordercolor=black>
  <tr> 
    <td width="100%" background="includes/grad.jpg"><center class=bold>
      Gym card
      </center></td>
  </tr>
  <tr> 
    <td height="10"><table width="100%" border="0" cellspacing="3" cellpadding="0">
        <tr> 
          <td width="100%"><div align="center"><a href="boxing.php">Click here 
              to signup for a gym pass it costs £1000</a></div></td>
        </tr>
      </table></td>
  </tr>
</table><? }else{
if (strip_tags($_POST['train']) && strip_tags($_POST['choice'])){
if ($info->last_train > time()){
echo "Wow speedy chill abit you must wait ".maketime($info->last_train)."";
}else{

$choice=strip_tags($_POST['choice']);
if ($choice == "1" || $choice == "2" || $choice == "3"){
if ($choice == "1"){
$plus="5";
$wait="1";
}elseif ($choice == "2"){
$plus="10";
$wait="5";
}elseif ($choice == "3"){
$plus="15";
$wait="10";
}
$new_exp=$info->exp + $plus;
$now=time()+ (60*$wait);
if ($new_exp >= "100"){
$new_lvl=$info->level+1;
$left=$new_exp-100;
mysql_query("UPDATE user_info SET exp='$left', level='$new_lvl', last_train='$now' WHERE username='$username'");
echo "You Successfully Trained.. And grew up a level!";
}else{
mysql_query("UPDATE user_info SET exp='$new_exp', last_train='$now' WHERE username='$username'");
echo "You successfully trained!";
}
}}}



if (strip_tags($_POST['create_button']) && strip_tags($_POST['create_bet'])){
$create_bet=intval(strip_tags($_POST['create_bet']));
if ($create_bet == 0 || !$create_bet || ereg('[^0-9]',$create_bet)){
print "You cant bet that amount.";

}elseif ($create_bet != 0 && $create_bet && !ereg('[^0-9]',$create_bet)){
if ($create_bet > $fetch->money){
echo "Are You Drunk You Dont Have Enough Cash!";
}elseif ($create_bet <= $fetch->money){
$already=mysql_num_rows(mysql_query("SELECT * FROM matches WHERE username='$username'"));
if ($already != "0"){
echo "You Are Already In a Match! LMAO";
}elseif ($already == "0"){


mysql_query("INSERT INTO `matches` ( `id` , `username` , `bet` ) 
VALUES (
'', '$username', '$create_bet'
)");
$new_money=$fetch->money - $create_bet;
mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
echo "Match Created";
}}}}

if (strip_tags($_POST['play_id']) && strip_tags($_POST['Submit'])){
$play_id=strip_tags($_POST['play_id']);
$match_info=mysql_query("SELECT * FROM matches WHERE id='$play_id'");
$num = mysql_num_rows($match_info);
$match_fetch=mysql_fetch_object($match_info);
if ($num == "0"){
echo "No such match.";
}elseif ($num != "0"){
if ($match_fetch->bet > $fetch->money){
echo "You do not have enough money to play this game.";
}elseif($match_fetch->bet <= $fetch->money){
if (strtolower($match_fetch->username) == strtolower($username)){
echo "You cannot play yourself sado.";
}elseif (strtolower($match_fetch) != strtolower($username)){
$oppon = mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$match_fetch->username'"));
$oppon_user = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$match_fetch->username'"));
$wl=explode(":",$oppon->wl);
////FINSHIED ALL SHITTY FETCHING

if ($oppon->level == $info->level && $oppon->exp == $info->exp){
echo "And..... its a draw!";
$new_money=$oppon_user->money + $match_fetch->bet;
mysql_query("UPDATE users SET money='$new_money' WHERE username='$match_fetch->username'");

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) 
VALUES (
'', '$match_fetch->username', '$match_fetch->username', 'You <b>Drew</b> in an arm wrestle!', '$date', '0', '0', '0'
)");


}elseif ($oppon->level > $info->level){
echo "And..... You lost!";
$new_money=$oppon_user->money + ($match_fetch->bet * 2);
mysql_query("UPDATE users SET money='$new_money' WHERE username='$match_fetch->username'");
$your_money=$fetch->money - $match_fetch->bet;
mysql_query("UPDATE users SET money='$your_money' WHERE username='$username'");


$new_stats = $stats[1] + 1;
$new_stats="$stats[0]:$new_stats";
mysql_query("UPDATE user_info SET wl='$new_stats' WHERE username='$username'");

$new_ekk = $wl[0] + 1;
$new_e="$new_ekk:$wl[0]";
mysql_query("UPDATE user_info SET wl='$new_e' WHERE username='$oppon->username'");

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) 
VALUES (
'', '$match_fetch->username', '$match_fetch->username', 'You <b>Won</b> in an arm wrestle!', '$date', '0', '0', '0'
)");


}elseif ($oppon->level == $info->level && $oppon->exp > $info->exp){
echo "And..... You lost!";
$new_money=$oppon_user->money + ($match_fetch->bet * 2);
mysql_query("UPDATE users SET money='$new_money' WHERE username='$match_fetch->username'");
$your_money=$fetch->money - $match_fetch->bet;
mysql_query("UPDATE users SET money='$your_money' WHERE username='$username'");

$new_stats = $stats[1] + 1;
$new_stats="$stats[0]:$new_stats";
mysql_query("UPDATE user_info SET wl='$new_stats' WHERE username='$username'");

$new_ekk = $wl[0] + 1;
$new_e="$new_ekk:$wl[1]";
mysql_query("UPDATE user_info SET wl='$new_e' WHERE username='$oppon->username'");

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) 
VALUES (
'', '$match_fetch->username', '$match_fetch->username', 'You <b>Won</b> in an arm wrestle!', '$date', '0', '0', '0'
)");
///////WINNING

}elseif ($oppon->level < $info->level){
echo "And.... You won!";
$new_money=$fetch->money + $match_fetch->bet;
mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");

$new_stats = $stats[0] +1;
$new_stats="$new_stats:$stats[1]";
mysql_query("UPDATE user_info SET wl='$new_stats' WHERE username='$username'");

$new_ekk = $wl[1] +1;
$new_e="$wl[0]:$new_ekk";
mysql_query("UPDATE user_info SET wl='$new_e' WHERE username='$oppon->username'");
mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) 
VALUES (
'', '$match_fetch->username', '$match_fetch->username', 'You <b>Lost</b> in an arm wrestle!', '$date', '0', '0', '0'
)");


}elseif ($oppon->level == $info->level && $oppon->exp < $info->exp){
echo "And.... You won!";
$new_money=$fetch->money + $match_fetch->bet;

mysql_query("UPDATE users SET money='$new_money' WHERE username='$username'");
$new_stats = $stats[0] +1;
$new_stats="$new_stats:$stats[1]";
mysql_query("UPDATE user_info SET wl='$new_stats' WHERE username='$username'");

$new_ekk = $wl[1] +1;
$new_e="$wl[0]:$new_ekk";
mysql_query("UPDATE user_info SET wl='$new_e' WHERE username='$oppon->username'");

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) 
VALUES (
'', '$match_fetch->username', '$match_fetch->username', 'You <b>Lost</b> in an arm wrestle!', '$date', '0', '0', '0'
)");


}
mysql_query("DELETE FROM matches WHERE id='$play_id'");
}}}}



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

<body>

<table width="770" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr> 
    <td colspan="2" rowspan="2" valign="top"><table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="black" class=thinline>
        <!--DWLayoutTable-->
        <tr> 
          <td  colspan="2" background="includes/grad.jpg"><div align="center" class=bold><strong>Start 
              Training</strong></div></td>
        </tr>
        <tr bgcolor=white> 
          <td height="25" colspan="2" class=tip><div align="center"><strong>Choose 
              a exercise</strong></div></td>
        </tr>
        <tr> 
          <td width="199" height="25"><strong> 
            <input name="choice" type="radio" value="1" checked>
            10 Situps</strong></td>
          <td width="178" height="25"><strong>+5</strong></td>
        </tr>
        <tr> 
          <td height="12"><strong> 
            <input name="choice" type="radio" value="2">
            5 Pressups</strong></td>
          <td height="12"><strong>+10</strong></td>
        </tr>
        <tr> 
          <td height="13"><strong> 
            <input name="choice" type="radio" value="3">
            1 Lap of swimming pool</strong></td>
          <td height="13"><strong>+15</strong></td>
        </tr>
        <tr> 
          <td height="25"> </td>
          <td height="25"><strong> 
            <input name="train" type="submit" id="train2" value="Train">
            </strong></td>
        </tr>
      </table>
       </td>
    <td height="146" colspan="2" valign="top"> 
      <table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="black"  class=thinline>
        <!--DWLayoutTable-->
        <tr> 
          <td  colspan="2" background="includes/grad.jpg"><div align="center"><strong>Your 
              Stats</strong></div></td>
        </tr>
        <tr> 
          <td width="196" height="25"><strong>Level:</strong></td>
          <td width="179"><strong><?php echo "$info->level"; ?></strong></td>
        </tr>
        <tr> 
          <td height="25"><strong>Current Experience:</strong></td>
          <td height="25"><table width="<?php echo "$info->exp"; ?>%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CC0000">
              <!--DWLayoutTable-->
              <tr> 
                <td width="16" height="1"></td>
                <td width="2"></td>
              </tr>
              <tr> 
                <td height="17" valign="top" bgcolor="#CC0000"><strong><?php echo "$info->exp%"; ?></strong></td>
                <td></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="25"><strong>Your wins:</strong></td>
          <td height="25"><strong><?php echo "$stats[0]"; ?></strong></td>
        </tr>
        <tr> 
          <td height="25"><strong>Your looses</strong></td>
          <td height="25"><strong><?php echo "$stats[1]"; ?></strong></td>
        </tr>
      </table>
       </td>
    <td width="21"> </td>
  </tr>
  <tr> 
    <td width="269" height="30"> </td>
    <td width="107"> </td>
    <td> </td>
  </tr>
  <tr> 
    <td width="163" height="14"></td>
    <td width="210"></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="247"></td>
    <td colspan="2" valign="top"><table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="black"  class=thinline>
          <!--DWLayoutTable-->
          <tr> 
            <td background="includes/grad.jpg" colspan="3"><div align="center"><strong>Current 
                Matches</strong></div></td>
          </tr>
          <tr bgcolor=white> 
            <td width="124" height="13" class=tip><strong>Username</strong></td>
            <td width="122" class=tip><strong>Bet</strong></td>
            <td width="123" class=tip><strong>Wins:Looses</strong></td>
          </tr>
          <?php $select=mysql_query("SELECT * FROM matches ORDER by bet DESC");
   while($dada = mysql_fetch_object($select)){
   $ls =mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$dada->username'"));
  $explode=explode(":", $ls->wl);
  
   echo "
    <tr> 
          <td><input type=radio name=play_id value=$dada->id>$dada->username</td>
          <td>£".makecomma($dada->bet)."</td>
          <td>$explode[0]:$explode[1]</td>
        </tr>";
	}
	?>
          <tr > 
            <td height="12" colspan="3" ><div align="center"> <strong> 
                <input type="submit" name="Submit" value="Submit">
                </strong></div></td>
          </tr>
        </table>
       <br>
      <br>
<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="black" class=thinline>
          <!--DWLayoutTable-->
          <tr> 
            <td background="includes/grad.jpg" colspan="2"><div align="center"><strong>Create 
              a Match</strong></div></td>
          </tr>
          <tr> 
            
          <td width="177" height="25"><strong>Bet:</strong></td>
            <td width="195"><strong> 
              <input name="create_bet" type="text" id="create_bet2">
              </strong></td>
          </tr>
          <tr> 
            <td height="25"> </td>
            <td height="25"><strong> 
              <input name="create_button" type="submit" id="create_button" value="Submit">
              </strong></td>
          </tr>
        </table>    </td>
    <td> </td>
    <td></td>
  </tr>
  <tr>
    <td height="74"></td>
    <td> </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>
</body>
</html>
<?php } ?>
<?php include_once"includes/footer.php"; ?>

Link to comment
https://forums.phpfreaks.com/topic/176766-php-error-helpnever-seen-this-code-b4/
Share on other sites

if (strtolower($match_fetch->username) == strtolower($username)){
echo "You cannot play yourself sado.";
}elseif (strtolower($match_fetch) != strtolower($username)){

 

$match_fetch is an object. In the relevant code above (does anyone read their code after they write it, especially when it produces an error?) you are referencing $match_fetch->username in the == comparison. I would bet the intent is to reference $match_fetch->username in the != comparison.

You would need to determine under what repeatable conditions the problem occurs.

 

If it is after a specific amount of time (say 24 minutes) with the browser displaying one page, it is likely due to the session ending due to session garbage collection running and deleting old (based on the last access time) session data files.

 

Is it only on one page? On any page, but after sitting there for an amount of time? When switching between specific pages?

Are you on a shared web server? If so, have you set your session.save_path setting to point to a private folder within your account's folder tree so that your session data files will only be affected by your session settings?

 

It's likely that some other account has set session.gc_maxlifetime to a short value in a misguided attempt to use it to log people out, but when session garbage collection runs it deletes your session data files using the shorter session.gc_maxlifetime setting in affect at the time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.