Jump to content

Php marry tool


Alienware

Recommended Posts

I have made a marry tool on my online game.

 

however when a user clicks "submit" the page comes up with "you cannot afford that" no matter how much money you in your account.

 

Anyone have any ideas?

 

here is the code-

 

<?php
require("connections/db.php");
require("connections/require.php");
require("connections/jailed.php");
$playername=$_SESSION['playername'];

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM players WHERE playername='$playername'"));
if (strip_tags($_POST['Submit']) && strip_tags($_POST['name'])){
$name=strip_tags($_POST['name']);
$ring=strip_tags($_POST['ring']);
if (!$name){
echo "Please enter the name of the person whom you wish to marry.";
}elseif ($name){
if ($ring == "1"){
$price="100000";
$ring_type="Cheap ass ring";
}elseif ($ring == "2"){
$price ="500000";
$ring_type="Golden Ring";
}elseif ($ring == "3"){
$price ="1000000";
$ring_type="Diamond Ring";
}elseif ($ring == "4"){
$price ="10000000";
$ring_type="Beers Diamond Ring";
}
$total = 10000 + $price;

if ($total > $money){
$error = "You can't afford that.";
error($error);
}else{
$newmoney = $money - $total;

$new_money=$fetch->money - $total;
$married_tr=mysql_num_rows(mysql_query("SELECT * 
FROM `married` 
WHERE `done` = '1'
AND `starter` = '$playername'
OR `other` = '$playername'"));
if ($married_tr != "0"){
echo "Your already married!";
}elseif($married_tr == "0"){
$married_tt=mysql_num_rows(mysql_query("SELECT * 
FROM `married` 
WHERE `done` = '1'
AND `starter` = '$name'
OR `other` = '$name'"));
if ($married_tt != "0"){
echo "This user is not single.";
}elseif ($married_tt == "0"){

mysql_query("INSERT INTO `married` ( `id` , `starter` , `other` , `done` , `ring` ) 
VALUES (
'', '$playername', '$name', '0', '$ring_type'
)");
$invite_text="<form name=marriage method=post action='?accept=marry&marrie_who=$playername'>
  <div align=center>You have been asked to marry $playername, you got 2 options:<br>
    <input name=Decline type=submit id=Decline value=Decline>
    | 
    <input name=Accept_marriage type=submit id=Accept value=Accept>
  </div>
</form>";

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) 
VALUES (
'', '$name', '$playername', '$invite_text', '$date', '0'
)");

echo "You asked $name to marry you!";

}}}}}
if (strip_tags($_POST['div'])){


$c=mysql_num_rows(mysql_query("SELECT * FROM married WHERE starter='$playername' OR other='$playername' AND done='1'"));
if ($c == "0"){
echo "Your not married.";
}elseif ($c != "0"){

mysql_query("DELETE FROM married WHERE starter='$playername' OR other='$playername'");
echo "You divorced your partner.";
$new_money=$fetch->money - 1000000;
mysql_query("UPDATE players SET money='$new_money' WHERE playername='$playername'");


mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) 
VALUES (
'', '$name', '$playername', '$playername has divorced you.', '$date', '0'
)");

}



}
?>
<html>
<head>
<title>NY-Church</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="includes/in.css" rel="stylesheet" type="text/css">
</head>

<body>
<form name="form1" method="post" action="">
  <table width="82%" border="1" align="center" cellpadding="0" cellspacing="0" class=thinline rules=none>
    <tr> 
      <td class=header><center>
        Propose
        </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr> 
      <td><table width="100%" border="1" cellspacing="3" cellpadding="0" bordercolor=black>
          <tr> 
            <td colspan="3"><div align="center">Welcome to <?php echo "$fetch->location"; ?>'s 
                church.</div></td>
          </tr>
          <tr> 
            <td colspan="3"><div align="center">It will cost £10,000 for 
                every request you make</div></td>
          </tr>
          <tr> 
            <td width="32%"><div align="center">Who do you wish to marry: </div></td>
            <td width="36%"><input name="name" type="text" id="units" size="10" maxlength="100"></td>
            <td width="32%"><img src="images/church.jpg" name="img" width="150" height="150" border="1" id="img"></td>
          </tr>
          <tr> 
            <td width="32%"><div align="center">What kind of ring do you want 
                to buy him/her: </div></td>
            <td width="36%"> <select size="1" name="ring">
                <option value="1">Some cheap ass ring - 100,000</option>
                <option value="2" >Golden ring - 500,000</option>
                <option value="3">Diamond ring - 1,000,000</option>
                <option value="4">Beers diamond ring - 10,000,000</option>
              </select> </td>
            <td width="32%"> </td>
          </tr>
          <tr> 
            <td> </td>
            <td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <br>
  <br>
  <table width="82%" border="1" align="center" cellpadding="0" cellspacing="0" class=thinline rules=none bordercolor=black>
    <tr> 
      <td class=header><center>
          Divorce
        </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr> 
      <td><table width="100%" border="0" cellspacing="3" cellpadding="0" bordercolor=black>
          <tr> 
            <td width="618"><div align="center">Welcome to <?php echo "$fetch->location"; ?>'s 
                church.</div></td>
          </tr>
          <tr> 
            <td><div align="center">It will cost £1,000,000 for every divorce 
                you make. Its a good idea to inform your wife/husband before you 
                divorce, therefore you can split the cost.</div></td>
          </tr>
          <tr> 
            <td><div align="center"> 
                <input name="div" type="submit" id="divorce" value="Divorce">
              </div></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <br>
  <table width="82%" border="1" align="center" cellpadding="2" cellspacing="0" class=thinline rules=none>
    <tr> 
      <td colspan="3" class=header height=20><center>
          Last 5 proposals </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr bgcolor=white bordercolor=black> 
      <td width="33%" class=tip>Proposed</td>
      <td width="30%" class=tip>To</td>
      <td width="37%" class=tip>Ring</td>
    </tr>
    
    <?php $query=mysql_query("SELECT * FROM married WHERE done='0' ORDER BY id DESC");
$nums=mysql_num_rows($query);
if($num=="0"){ echo "<tr> 
      <td colspan=3>No recent proposals</td>
    </tr>"; 
}
while($obby=mysql_fetch_object($query)){
echo "
    <tr>
      <td><a href='profile.php?viewplayer=$obby->starter'>$obby->starter</a></td>
      <td><a href='profile.php?viewplayer=$obby->other'>$obby->other</a></td>
      <td>$obby->ring</td>
    </tr>";
}
?>
  </table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/133650-php-marry-tool/
Share on other sites

$total isnt defined. Try using:

if ($price > $money){
$error = "You can't afford that.";
error($error);
?>

 

instead of your original:

if ($total > $money){
$error = "You can't afford that.";
error($error);
?>

 

1) Those are exactly the same.

2) Total IS defined:

 

$total = 10000 + $price;

Link to comment
https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695343
Share on other sites

ok i have done that.

 

Now it is saying-

 

Fatal error: Cannot use object of type stdClass as array in /home2/nymobste/public_html/marry.php on line 15

 

 

this is the code-

 

<?php
require("connections/db.php");
require("connections/require.php");
require("connections/jailed.php");
$playername=$_SESSION['playername'];

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM players WHERE playername='$playername'"));
if (strip_tags($_POST['Submit']) && strip_tags($_POST['name'])){
$name=strip_tags($_POST['name']);
$ring=strip_tags($_POST['ring']);

if (!$name){
echo "Please enter the name of the person whom you wish to marry.";
}elseif ($name){
$money = $fetch[money];
if ($ring == "1"){
$price="100000";
$ring_type="Cheap ass ring";
}elseif ($ring == "2"){
$price ="500000";
$ring_type="Golden Ring";
}elseif ($ring == "3"){
$price ="1000000";
$ring_type="Diamond Ring";
}elseif ($ring == "4"){
$price ="10000000";
$ring_type="Beers Diamond Ring";
}
$total = 10000 + $price;

if ($total > $money){
$error = "You can't afford that.";
error($error);
}else{
$newmoney = $money - $total;

$new_money=$fetch->money - $total;
$married_tr=mysql_num_rows(mysql_query("SELECT * 
FROM `married` 
WHERE `done` = '1'
AND `starter` = '$playername'
OR `other` = '$playername'"));
if ($married_tr != "0"){
echo "Your already married!";
}elseif($married_tr == "0"){
$married_tt=mysql_num_rows(mysql_query("SELECT * 
FROM `married` 
WHERE `done` = '1'
AND `starter` = '$name'
OR `other` = '$name'"));
if ($married_tt != "0"){
echo "This user is not single.";
}elseif ($married_tt == "0"){

mysql_query("INSERT INTO `married` ( `id` , `starter` , `other` , `done` , `ring` ) 
VALUES (
'', '$playername', '$name', '0', '$ring_type'
)");
$invite_text="<form name=marriage method=post action='?accept=marry&marrie_who=$playername'>
  <div align=center>You have been asked to marry $playername, you got 2 options:<br>
    <input name=Decline type=submit id=Decline value=Decline>
    | 
    <input name=Accept_marriage type=submit id=Accept value=Accept>
  </div>
</form>";

mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) 
VALUES (
'', '$name', '$playername', '$invite_text', '$date', '0'
)");

echo "You asked $name to marry you!";

}}}}}
if (strip_tags($_POST['div'])){


$c=mysql_num_rows(mysql_query("SELECT * FROM married WHERE starter='$playername' OR other='$playername' AND done='1'"));
if ($c == "0"){
echo "Your not married.";
}elseif ($c != "0"){

mysql_query("DELETE FROM married WHERE starter='$playername' OR other='$playername'");
echo "You divorced your partner.";
$new_money=$fetch->money - 1000000;
mysql_query("UPDATE players SET money='$new_money' WHERE playername='$playername'");


mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) 
VALUES (
'', '$name', '$playername', '$playername has divorced you.', '$date', '0'
)");

}



}
?>
<html>
<head>
<title>NY-Church</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="includes/in.css" rel="stylesheet" type="text/css">
</head>

<body>
<form name="form1" method="post" action="">
  <table width="82%" border="1" align="center" cellpadding="0" cellspacing="0" class=thinline rules=none>
    <tr> 
      <td class=header><center>
        Propose
        </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr> 
      <td><table width="100%" border="1" cellspacing="3" cellpadding="0" bordercolor=black>
          <tr> 
            <td colspan="3"><div align="center">Welcome to <?php echo "$fetch->location"; ?>'s 
                church.</div></td>
          </tr>
          <tr> 
            <td colspan="3"><div align="center">It will cost £10,000 for 
                every request you make</div></td>
          </tr>
          <tr> 
            <td width="32%"><div align="center">Who do you wish to marry: </div></td>
            <td width="36%"><input name="name" type="text" id="units" size="10" maxlength="100"></td>
            <td width="32%"><img src="images/church.jpg" name="img" width="150" height="150" border="1" id="img"></td>
          </tr>
          <tr> 
            <td width="32%"><div align="center">What kind of ring do you want 
                to buy him/her: </div></td>
            <td width="36%"> <select size="1" name="ring">
                <option value="1">Some cheap ass ring - 100,000</option>
                <option value="2" >Golden ring - 500,000</option>
                <option value="3">Diamond ring - 1,000,000</option>
                <option value="4">Beers diamond ring - 10,000,000</option>
              </select> </td>
            <td width="32%"> </td>
          </tr>
          <tr> 
            <td> </td>
            <td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <br>
  <br>
  <table width="82%" border="1" align="center" cellpadding="0" cellspacing="0" class=thinline rules=none bordercolor=black>
    <tr> 
      <td class=header><center>
          Divorce
        </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr> 
      <td><table width="100%" border="0" cellspacing="3" cellpadding="0" bordercolor=black>
          <tr> 
            <td width="618"><div align="center">Welcome to <?php echo "$fetch->location"; ?>'s 
                church.</div></td>
          </tr>
          <tr> 
            <td><div align="center">It will cost £1,000,000 for every divorce 
                you make. Its a good idea to inform your wife/husband before you 
                divorce, therefore you can split the cost.</div></td>
          </tr>
          <tr> 
            <td><div align="center"> 
                <input name="div" type="submit" id="divorce" value="Divorce">
              </div></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <br>
  <table width="82%" border="1" align="center" cellpadding="2" cellspacing="0" class=thinline rules=none>
    <tr> 
      <td colspan="3" class=header height=20><center>
          Last 5 proposals </center></td>
    </tr>
 <tr bgcolor=black><td height=1 colspan=3></td></tr>
    <tr bgcolor=white bordercolor=black> 
      <td width="33%" class=tip>Proposed</td>
      <td width="30%" class=tip>To</td>
      <td width="37%" class=tip>Ring</td>
    </tr>
    
    <?php $query=mysql_query("SELECT * FROM married WHERE done='0' ORDER BY id DESC");
$nums=mysql_num_rows($query);
if($num=="0"){ echo "<tr> 
      <td colspan=3>No recent proposals</td>
    </tr>"; 
}
while($obby=mysql_fetch_object($query)){
echo "
    <tr>
      <td><a href='profile.php?viewplayer=$obby->starter'>$obby->starter</a></td>
      <td><a href='profile.php?viewplayer=$obby->other'>$obby->other</a></td>
      <td>$obby->ring</td>
    </tr>";
}
?>
  </table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695406
Share on other sites

hmmmmm.

i have the correct $money, etc.

I don't see how that is possible.

I do, it was correctly reading the value of $money from the fetched player record later on in the script, and displaying it then was showing a correct value... but it hadn't been transferred from the fetched player record to the $money variable at the earlier point in the script when it was doing that comparison

Link to comment
https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695536
Share on other sites

Archived

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

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