SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP - Not Replacing Variable With Data

    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.

    PHP Code:
    $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.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  2. #2
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump*
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  3. #3
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    We'll need to see more of your code. Where do you set the value of $pixelurl?
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  4. #4
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here you go

    PHP Code:

    $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
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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="

  6. #6
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already have in the first post.

    Thanks
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AdWarm View Post
    I already have in the first post.

    Thanks
    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:

    PHP Code:
    $subid=$_COOKIE["lnm_lead_subid"];
    $adid=$_GET["adid"];

    $string $pixelurl;
    $string addslashes(str_replace(array('$subid''$adid'), array($subid$adid), $string));
    echo 
    $string

  8. #8
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep that's fixed the issue.

    Thanks
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •