Jump to content

orre

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

orre's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am inplanting a bonus system to a game i have. I want to say at first that i am not good at php am reading alot and go by learn by doing. But after a few hours i kinda gave up. Here is the code. The page end up blank. And i tested so my syntax work $cost and $points with only the db stuff and this code <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> <div class="yellow_12_bold"><? print (number_format($cost)); ?> </div> And it does. Anyway here is the code <? $dbq = $db->execute("select * from Bonus where username='$username'"); $points = $dbq->fields['points']; $allpoints = $dbq->fields['points_total']; $dbq->close(); if ($cost == "5" && $amount == "3000") { if ($points == "5" || $points > "5") { $sqlb = "update UserData set turns=turns+'3000' WHERE turns < 50000 and location != '9' and frozen = '0'"; $result1 = mysql_query($sqlb); $sqlc = "update Bonus set points=points-'5' WHERE username = '$username'; $result2 = mysql_query($sqlb); $points2 = ($points - 5); <p align="center" class="black">Thank you! 3000 turns have been added to everyone. You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left. </p> } else { <p align="center" class="black">Sorry you dont have $cost points. You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left.</p> } } ?>
  2. After playing with it for a while i made it look ugly but it works. Is there way to get it look better? Do i need to use some kind of loop? Heres the code that works. if ($item_number == '301') { $bonus1 = "update Bonus set points=points+'1' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'1' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set smal_turns='smal_turns'+1 where username='$username'"; mysql_query("$bonus3"); } elseif ($item_number == '302') { $bonus1 = "update Bonus set points=points+'2' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'2' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set medium_turns='medium_turns'+1 where username='$username'"; mysql_query("$bonus3"); } elseif ($item_number == '303') { $bonus1 = "update Bonus set points=points+'3' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'3' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set big_turns='big_turns'+1 where username='$username'"; mysql_query("$bonus3"); } else { $bonus1 = "update Bonus set points=points+'0' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'0' where username='$username'"; mysql_query("$bonus2");
  3. n/m i figured it out with the print command. update Bonus set points=points+'' where username='lotan' update Bonus set points_total=points_total+'' where username='lotan' update Bonus set 301=301+1 where username='lotan' ( found the error on this one took the $item_number out) This is what it output. So the if,elseif things dont seem to work proper for some reson. Or do i need to have them in the same while function?
  4. Thanks! I did have if,elseif,elseif,else in my first try. forgot the edit it back was playing with it sorry. Now the script works agin after i fixed the $points But it still doesnt insert Those lines at all. $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); But it do insert $ttlpay_sql = "update totalpay set total=total+'$payment_amount' where id='1'"; mysql_query("$ttlpay_sql"); So my question is, is there a way to echo my varibels to a file? some how lets say "print $bonus1 " And it would print something like "update Bonus set points=points+'1' where username='testuser" For debbuging. Cuse i cant se any errors at all the Table is named Bonus and when i try to run update Bonus set points=points+'1' where username='testuser in my MYSQL it works. I know this is basic stuff, am reading some tutorials atm, but i like the "learn by doing" Thanks /Orre
  5. I got a script that receive info from paypal "ipn" when someone is making a payment from my shop. I wanted to edit the script a bit as i am adding a bonus system to it. After i added And The script wont work. But it does when i remove those things. I think my problem is at the if,elseif i just dont know why. Do i need to put it in some kind of while loop? Here is the full php code mysql_connect('xxxxx', 'xxxx', 'xxxxxx'); $notify_email = "xxxx@xxxx"; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $buyer_firstname = $_POST['first_name']; $buyer_lastname = $_POST['last_name']; $timestamp = $_POST['payment_date']; $address_street = $_POST['address_street']; $address_city = $_POST['address_city']; $address_state = $_POST['address_state']; $address_zip = $_POST['address_zip']; $username = $_POST['custom']; // Bonus system vars if ($item_name == '301') { $point == "1"; } elseif ($item_name == '302') { $point == "2"; } elseif ($item_name == '303') { $point == "3"; } elseif { $point == "0"; } mysql_select_db('redlite'); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status == 'Completed') { $sql = "insert into tblMail values ('','$txn_id','$payer_email',' $item_name','$timestamp','','','','$payment_amount $payment_currency','$buyer_firstname $buyer_lastname','$address_street $address_city , $address_state $address_zip','','','$username')"; mysql_query("$sql"); $bonus1 = "update Bonus set points=points+'$points' where username='$username'"; mysql_query("$bonus1"); $bonus2 = "update Bonus set points_total=points_total+'$points' where username='$username'"; mysql_query("$bonus2"); $bonus3 = "update Bonus set $item_name=$item_name+1 where username='$username'"; mysql_query("$bonus3"); $ttlpay_sql = "update totalpay set total=total+'$payment_amount' where id='1'"; mysql_query("$ttlpay_sql"); mail($notify_email, "CLVerified", "$res\n $req"); } else { mail($notify_email, "CLVerified - But not completed". "$res\n $req"); } } else if (strcmp ($res, "INVALID") == 0) { mail($notify_email, "CLINVALID IPN", "$res\n $req"); } } fclose ($fp); } ?>
×
×
  • 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.