Reputation: 427
I am trying to build a universal postback system for a GPT script and well I am having just a bit of a problem.
I am not sure if what I am doing is allowed in PHP so that may be the problem, but this is what I got:
$ip = cleanQuery($_SERVER['REMOTE_ADDR']);
$getaffip = mysql_query("SELECT * FROM affiliates WHERE affip = '".$ip."' OR affip2 = '".$ip."' OR affip3 = '".$ip."' OR affip4 = '".$ip."'");
$affinfo = mysql_fetch_array($getaffip);
$affname = $affinfo['name'];
$campidi = $affinfo['campid'];
$subidi = $affinfo['subid'];
$ratei = $affinfo['rateid'];
$statusi = $affinfo['creditstatus'];
$credit = $affinfo['creditid'];
$reverse = $affinfo['reverseid'];
$subid = cleanQuery($_GET['$subidi']);
$rate = cleanQuery($_GET['$ratei']);
$status = cleanQuery($_GET['$statusi']);
$campid = cleanQuery($_GET['$campidi']);
what this means is it is pulling the variables that particular affiliate uses when they send the information to your postback, for example they would send this to the postback URL:
http://yoursite.com/postback/postback.php?campaignid=11546&yti=me&credit=1
the $affinfo
fetches would pull the defined info that the particular affiliate sends like in the link above $subidi
for the affiliate that posted it would be yti
and $campidi
would be campaignid
, but the $_GET
isn't pulling that information. It works if I change it to $_GET['yti']
; in this case, but that wouldn't make it universal as all affiliates do not use the same variables when they send information to the postback script.
I am thinking that the $_GET
doesn't support the $values
, so what would be my best route of making it get the right information, or do I just have some kind of typo here that I have overlooked?
Upvotes: 1
Views: 199
Reputation: 270637
Do not quote the keys if they are variables:
$subid = cleanQuery($_GET[$subidi]);
$rate = cleanQuery($_GET[$ratei]);
$status = cleanQuery($_GET[$statusi]);
$campid = cleanQuery($_GET[$campidi]);
It would have worked if you had used double quotes instead of single, but that would be pointless and poor practice to needlessly quote variables. The variables would have been interpolated inside the double quotes, ultimately giving the result you were after.
Upvotes: 7
Reputation: 32155
Variables in single quotes aren't evaluated. Double quotes are.
$foo = 'var';
echo 'my $foo'; // my $foo
echo "my $foo"; // my var
But you shouldn't be using any quotes in this situation
Upvotes: 4
Reputation: 1350
Too many quotes :) Should be like this:
$subid = cleanQuery($_GET[$subidi]);
$rate = cleanQuery($_GET[$ratei]);
$status = cleanQuery($_GET[$statusi]);
$campid = cleanQuery($_GET[$campidi]);
Upvotes: 5