1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reward Script Error

Discussion in 'PHP & Perl' started by necada, Oct 21, 2010.

  1. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67
    I am trying to get a Reward Script for CPA Offers to work

    But I have this error on Postback Test in CPA Lead

    PHP:
    <b>Warning</b>:  Invalid argument supplied for foreach() in   <b>/home/xxxx/public_html/xxxxx.com/postback.php</b>  on  line <b>35</b><br />
    Successxx.xxx.xx.xxx earned 100 points
     
    and is referred by nobody                      
    Line 34-36 of the postback.php I have this code
    PHP:
    $query_checkRef mysql_query("SELECT referral_ID from members WHERE username= '".$subid."'") or die(mysql_error());
    foreach(
    mysql_fetch_array($query_checkRef) as $ref_id_user);
    if (
    $ref_id_user>=1)                      
    What am I doing wrong?
     
  2. paincake

    paincake Power Member

    Joined:
    Aug 18, 2010
    Messages:
    716
    Likes Received:
    3,099
    Home Page:
    Well, this error shows up when you try to feed something that's not an array into foreach function. I think what's happening is mysql_fetch_array is returning FALSE instead of an array with values. Try debugging. Comment out the 35th line and do print_r($query_checkRef) and see what happens. Most likely the sql query is not returning anything.

    Also make sure you use something like mysql_real_escape_string() on variables that users input and are included in sql queries (to prevent sql injection)
     
    • Thanks Thanks x 1
  3. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67
    Well Im a pretty newb with php, I can understand +/- what is there but my knowledge to modify something is not enought...

    I tried somethings with what u said tho, got no positive results... Would you mind giving a more in depth explanation?...

    Are you "pro" in php coding?... I would pay some bucks to have some more features and bug corrections on this script, since the guy that wrote it is not updating it anymore
     
  4. polix

    polix Registered Member

    Joined:
    Nov 30, 2008
    Messages:
    67
    Likes Received:
    40
    can you tell me what reward script are you using?
     
  5. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67
    mygeekvoucher rewards script...
     
  6. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67
    Any tip? I really need help with this
     
  7. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    Do you have members? Is the member id's id or username?
     
  8. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    I made postbacks for adscends and offerpal that work with this script.
     
  9. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67
    Those are other CPA networks Right?

    Would you like to share? :)


    I dont get what you mean with the members ids being id or username...
     
  10. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    In your database, is it id or username that is being used for the member id? Some reason it is producing nothing, so you either have the wrong name of a field, or you have no members. I have messed with my code, so I am just wondering if I changed mine to username, because I was polling their FB username id's and using them as a unique id.

    Yes, adscends and offerpal are CPA networks and are easy to get into. They have gateways that postback.
     
  11. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67

    I have both tabs in the db... The username tabs with the real username and the ID tabs with the ID ( for example 1st registered user has the ID 1, second has 2... and so on) If u have this script you should know that...

    So are you willing to share that postbacks? or are you selling them?

    And how can I solve the problem with the current CPA Lead Postback?

    And yes I have 1 registered user... My test account thats not working properly with the postback
     
    Last edited: Oct 25, 2010
  12. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    I told you why I may not know, I changed my database. I told you I dont use 1,2,3, I use their real FB id number.

    It is obvious that I had something more advanced than what you are trying to do. I had FB Connect working on it.

    No, I am not selling the postbacks, but it is obvious it wont work for yours. I think it is obvious that I know PHP and made my geekvoucher with a lot more options, so I dont get why you want to be the way you are when I was trying to help.
     
  13. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    Even though I am a liar and an idiot, here is my adscend postback I used

    Code:
    <?php
    /*
     * Basic Postback Example Script.
     * Copyright 2009. CPA Lead. All Rights Reserved
     */
     
    $YOURPASSWORD = ""; //this is the password you set when creating your widget
    $mysql_where = "localhost"; //hostname - usually localhost
    $mysql_username = "XXXXX"; //database username
    $mysql_password = "XXXXX"; //database password
    $mysql_database = "XXXXX"; //database name
    
    $password = $_REQUEST['password'];
    if ($password != $YOURPASSWORD) {
        echo "Access Denied";
        exit;
    }
    
    mysql_connect($mysql_where, $mysql_username, $mysql_password);
    mysql_select_db($mysql_database);
    
    /*
     * For a complete variable list see: http://www.*******.com/postback-variables.php (You must be logged in to view).
     */
    include("includes.php");
    
    
    $snuid = $_REQUEST['sid'];
    $currency = $_REQUEST['rate'];
    $ids = $_REQUEST['campid'];
    $verifier = $_REQUEST['status'];
    $affl = $_REQUEST['name'];
    
    $points = round($currency*15);
    
    $referpoints = round($points*.50);
    
    //$query_getuserid = mysql_query("SELECT id from members WHERE username= '".$snuid."'") or die(mysql_error());
    //foreach(mysql_fetch_array($query_getuserid) as $userid);
    
    $query_checkRef = mysql_query("SELECT referral_ID from members WHERE id= '".$snuid."'") or die(mysql_error());
    foreach(mysql_fetch_array($query_checkRef) as $ref_id_user);
    if ($ref_id_user>=1)
    {
    mysql_query("UPDATE members SET points=points+".$points." WHERE id='".$snuid."'");
    mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE id ='".$snuid."'");
    mysql_query("UPDATE members SET points=points+".$referpoints." WHERE id ='".$ref_id_user."'");
    $qrypay = "Insert into completed (snuid,currency,id,verifier,affl,survey,earned,affiliate) values('".$snuid."','".$points."','".$ids."','".$verifier."','".$affl."','','0','Adscend')";
    mysql_query($qrypay) or die(mysql_error());
    mysql_close();
    echo "Success: ".$snuid." earned ".$points." points\n and is referred by".$ref_id_user;
    }else {
    mysql_query("UPDATE members SET points=points+".$points." WHERE id='".$snuid."'");
    mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE id ='".$snuid."'");
    $qrypay = "Insert into completed (snuid,currency,id,verifier,affl,survey,earned,affiliate) values('".$snuid."','".$points."','".$ids."','".$verifier."','".$affl."','','0','Adscend')";
    mysql_query($qrypay) or die(mysql_error());
    mysql_close();
    echo "Success: ".$snuid." earned ".$points." points\n and is referred by nobody";
    } 
    
    ?>
     
  14. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    If I was you, I could fix it, but I am not you and dont have access to everything you do, so I really cant help.

    My last question is, Success: xx.xxx.xx.xxx earned 100 points

    Are the xx.xxx.xx.xxx representing a user id? or is that 4 postback items? Are you using a real id in your testing?
     
  15. necada

    necada Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    275
    Likes Received:
    67

    Im sorry I didnt mean that.. I noticed your knowledge in this matter is higher than mine, I'm only trying to get some help... ANd yes with FB connect your script is way more advanced... Also, you made it having mygeekvoucher script has a base or other script? Because there are also 1 or 2 rewards scripts around with fb connect

    Sorry If I seemed agressive or something

    The xx.xxx things were my IP and site address so I covered them...

    My test account has ID 1 and I test the postback with it logged in, It gives that error I said before and the points are not credited as they should in the test account
     
  16. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    My lines dont match up with yours for postback.php, mine are 2 lines down, so mine is like 37. See if I changed something on mine to make it work. It was in February so my memory is not that good.

    Code:
    <?php
    /*
     * Basic Postback Example Script.
     * Copyright 2009. CPA Lead. All Rights Reserved
     */
     
    $YOURPASSWORD = ""; //this is the password you set when creating your widget
    $mysql_where = "localhost"; //hostname - usually localhost
    $mysql_username = "XXXX"; //database username
    $mysql_password = "XXXX"; //database password
    $mysql_database = "XXXX"; //database name
    
    $password = $_REQUEST['password'];
    if ($password != $YOURPASSWORD) {
        echo "Access Denied";
        exit;
    }
    
    mysql_connect($mysql_where, $mysql_username, $mysql_password);
    mysql_select_db($mysql_database);
    
    /*
     * For a complete variable list see: http://www.*******.com/postback-variables.php (You must be logged in to view).
     */
    include("includes.php");
    $subid = $_REQUEST['subid'];
    $survey = $_REQUEST['survey'];
    $earn = $_REQUEST['earn'];
    $pdtshow = $_REQUEST['pdtshow'];
    
    $referpoints = ($pdtshow*.50);
    
    //$query_getuserid = mysql_query("SELECT id from members WHERE username= '".$subid."'") or die(mysql_error());
    //foreach(mysql_fetch_array($query_getuserid) as $userid);
    
    $query_checkRef = mysql_query("SELECT referral_ID from members WHERE id= '".$subid."'") or die(mysql_error());
    foreach(mysql_fetch_array($query_checkRef) as $ref_id_user);
    if ($ref_id_user>=1)
    {
    mysql_query("UPDATE members SET points=points+".$pdtshow." WHERE id='".$subid."'");
    mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE id ='".$subid."'");
    mysql_query("UPDATE members SET points=points+".$referpoints." WHERE id ='".$ref_id_user."'");
    $qrypay = "Insert into completed (snuid,currency,id,verifier,affl,survey,earned,affiliate) values('".$subid."','".$pdtshow."','".$ids."','".$verifier."','".$affl."','".$survey."','".$earn."','*******')";
    mysql_query($qrypay) or die(mysql_error());
    mysql_close();
    echo "Success: ".$subid." earned ".$pdtshow." points\n and is referred by".$ref_id_user;
    }else {
    mysql_query("UPDATE members SET points=points+".$pdtshow." WHERE id='".$subid."'");
    mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE id ='".$subid."'");
    $qrypay = "Insert into completed (snuid,currency,id,verifier,affl,survey,earned,affiliate) values('".$subid."','".$pdtshow."','".$ids."','".$verifier."','".$affl."','".$survey."','".$earn."','*******')";
    mysql_query($qrypay) or die(mysql_error());
    mysql_close();
    echo "Success: ".$subid." earned ".$pdtshow." points\n and is referred by nobody";
    } 
    
    ?>