Alienware Posted November 21, 2008 Share Posted November 21, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/ Share on other sites More sharing options...
ShiloVir Posted November 21, 2008 Share Posted November 21, 2008 $total isnt defined. Try using: <?php if ($price > $money){ $error = "You can't afford that."; error($error); ?> instead of your original: <?php if ($total > $money){ $error = "You can't afford that."; error($error); ?> Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695338 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 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. You mean marriage isn't always like that???? Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695339 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 lol!! and still no luck. It still says you can't affort that. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695341 Share on other sites More sharing options...
Maq Posted November 21, 2008 Share Posted November 21, 2008 $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; Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695343 Share on other sites More sharing options...
Maq Posted November 21, 2008 Share Posted November 21, 2008 I think you meant to say $money isn't defined... Try this: $money = 1; if ($total > $money){ $error = "You can't afford that."; error($error); Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695346 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 arghhhh im getting no where lol. still says it. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695350 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 could it be that the msql isnt being checked for the money? Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695352 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 MySqL* Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695354 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 ims till having no luck lol Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695385 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 could it be that the msql isnt being checked for the money? I think so. Should there be a: $money = $fetch['money]; somewhere before all the ring costs Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695390 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695406 Share on other sites More sharing options...
revraz Posted November 21, 2008 Share Posted November 21, 2008 echo $total and $money to see what they actually contain. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695412 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 hmmmmm. i have the correct $money, etc. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695427 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 Replace what I said earlier with $money = $fetch->money; Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695435 Share on other sites More sharing options...
revraz Posted November 21, 2008 Share Posted November 21, 2008 I don't see how that is possible. hmmmmm. i have the correct $money, etc. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695440 Share on other sites More sharing options...
Alienware Posted November 21, 2008 Author Share Posted November 21, 2008 Thankyou very much, that worked. thanks for all the help. Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695448 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133650-php-marry-tool/#findComment-695536 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.