JakeD Posted March 25, 2007 Share Posted March 25, 2007 <? $amount = $_POST['amount']; $id = $userdata['user_id']; $otherid = $_POST['id']; $usermoney = "user_money"; $money = $userdata['user_money']; $take = $money - $amount; $othermoney = dbquery("SELECT ".$usermoney." FROM ".$db_prefix."users WHERE user_id='".$otherid."'"); $omoney = mysql_fetch_row($othermoney); $omoney=$omoney[0]; $money = $omoney; $times = $amount / 2; $kill="false"; if ($amount > $money) { echo "<script language=\"Javascript\"> <!-- alert (\"Not enough money\") //--> </script>"; echo "<SCRIPT LANGUAGE=\"JavaScript\"> <!-- window.location=\"/\"; // --> </script>"; $kill = "fasleasdasdasdasdasdasdasd"; } if ($times >= $othermoney) { $kill="true"; } else { echo "Your hitman did not successfully kill the person he was attacking, and ran off with your money, pay him more next time"; dbquery("UPDATE ".$db_prefix."users SET user_money=".$take." WHERE user_id='".$id."'"); } if ($kill == "true") { $rwd = $money + $othermoney; echo "Successfully killed your target, they had \$$othermoney which is now yours."; dbquery("UPDATE ".$db_prefix."users SET user_money=".$rwd." WHERE user_id='".$id."'"); dbquery("DELETE FROM ".$db_prefix."users WHERE user_id='$otherid'"); dbquery("DELETE FROM ".$db_prefix."articles WHERE article_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."comments WHERE comment_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."messages WHERE message_to='$otherid'"); dbquery("DELETE FROM ".$db_prefix."messages WHERE message_from='$otherid'"); dbquery("DELETE FROM ".$db_prefix."news WHERE news_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."poll_votes WHERE vote_user='$otherid'"); dbquery("DELETE FROM ".$db_prefix."ratings WHERE rating_user='$otherid'"); dbquery("DELETE FROM ".$db_prefix."shoutbox WHERE shout_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."threads WHERE thread_author='$otherid'"); dbquery("DELETE FROM ".$db_prefix."posts WHERE post_author='$otherid'"); } ?> if ($amount > $money) i made $amount > $money, and it alerts the javascript....but it still runs the SQL querys! im getting so frustrated...it shouldnt because i put if ($kill == "true") to run it, and by default kill doesnt = true!!!! please help me:( thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/ Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 enclose everything after the first IF with else {Stuff here} this way it won't execute the sql Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/#findComment-214854 Share on other sites More sharing options...
JakeD Posted March 25, 2007 Author Share Posted March 25, 2007 Thanks for replying, so i would ad an else after the if? if ($amount > $money) { echo "<script language=\"Javascript\"> <!-- alert (\"Not enough money\") //--> </script>"; echo "<SCRIPT LANGUAGE=\"JavaScript\"> <!-- window.location=\"/\"; // --> </script>"; $kill = "fasleasdasdasdasdasdasdasd"; } else {echo "";} like so? Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/#findComment-214860 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 yup, and where you have that echo put the rest of your code: if ($times >= $othermoney) { $kill="true"; } else { echo "Your hitman did not successfully kill the person he was attacking, and ran off with your money, pay him more next time"; dbquery("UPDATE ".$db_prefix."users SET user_money=".$take." WHERE user_id='".$id."'"); } if ($kill == "true") { $rwd = $money + $othermoney; echo "Successfully killed your target, they had \$$othermoney which is now yours."; dbquery("UPDATE ".$db_prefix."users SET user_money=".$rwd." WHERE user_id='".$id."'"); dbquery("DELETE FROM ".$db_prefix."users WHERE user_id='$otherid'"); dbquery("DELETE FROM ".$db_prefix."articles WHERE article_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."comments WHERE comment_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."messages WHERE message_to='$otherid'"); dbquery("DELETE FROM ".$db_prefix."messages WHERE message_from='$otherid'"); dbquery("DELETE FROM ".$db_prefix."news WHERE news_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."poll_votes WHERE vote_user='$otherid'"); dbquery("DELETE FROM ".$db_prefix."ratings WHERE rating_user='$otherid'"); dbquery("DELETE FROM ".$db_prefix."shoutbox WHERE shout_name='$otherid'"); dbquery("DELETE FROM ".$db_prefix."threads WHERE thread_author='$otherid'"); dbquery("DELETE FROM ".$db_prefix."posts WHERE post_author='$otherid'"); } Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/#findComment-214862 Share on other sites More sharing options...
JakeD Posted March 25, 2007 Author Share Posted March 25, 2007 oooo, thanks a million man Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/#findComment-214866 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 no problem, glad I could help Quote Link to comment https://forums.phpfreaks.com/topic/44240-if-problem/#findComment-214881 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.