AdWarm
October 6, 2011, 11:20am
1
Hi Guys,
I am getting data from a database and in that data it has variables in there, so when the data is outputted the variables should be replaced, but this is not happening.
$subid=$_COOKIE["lnm_lead_subid"];
$adid=$_GET["adid"];
$string = $pixelurl;
$string = addslashes($string);
echo $string;
Output is below:
http://www.URL.com/tracking/RecordPixel.aspx?cmp=120&optional=$adid&optional2=$subid&optional3=
As you can see $adid and $subid are still in the output and have not been replaced. Any help would be great.
Thank you.
We’ll need to see more of your code. Where do you set the value of $pixelurl
?
AdWarm
October 6, 2011, 6:40pm
4
Here you go
$query2 = sprintf("SELECT Pixel FROM affpixels WHERE AffID ='%s' AND ProID ='%s'",
quote_smart($affid),
quote_smart($p));
mysql_query($query2) or dies(mysql_error());
$result2 = mysql_query($query2);
$pixelurl=$result2;
while($row = mysql_fetch_array($result2))
{
//echo $row['Pixel'];
$pixelurl=$row['Pixel'];
}
Any help would be great.
Thanks
JV1
October 6, 2011, 6:43pm
5
You are not providing enough to be able to determine the problem.
Can you post the code that echoes/prints the URL:
“http://www.URL.com/tracking/RecordPixel.aspx?cmp=120&optional=$adid&optional2=$subid&optional3= ”
AdWarm
October 6, 2011, 7:00pm
6
I already have in the first post.
Thanks
JV1
October 6, 2011, 7:08pm
7
Without having the entire script in front of me, my best guess is that you are pulling “http://www.URL.com/tracking/RecordPixel.aspx?cmp=120&optional=$adid&optional2=$subid&optional3= ” straight from the database and expecting $adid and $subid to be substituted in to it automagically, but that is not happening.
Try doing this:
$subid=$_COOKIE["lnm_lead_subid"];
$adid=$_GET["adid"];
$string = $pixelurl;
$string = addslashes(str_replace(array('$subid', '$adid'), array($subid, $adid), $string));
echo $string;
AdWarm
October 6, 2011, 7:15pm
8
Yep that’s fixed the issue.
Thanks