SitePoint Sponsor

User Tag List

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

    Passing Variable In URL - Not Working

    PHP Code:
    $iframecontent get_url('http://domain.com/data.ashx?id=270.126&sub_id=List5&gender=".$title."&firstname=".$first."&lastname=".$last."&email=".$email."&dob=".$dob."'); 
    Morning Guys!

    Hope you are all well, any reason why my variables are not being replaced with its value in the url?

    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
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    Because you're mixing up single quotes and double quotes.

    PHP Code:
    $iframecontent get_url('http://domain.com/data.ashx?id=270.126&sub_id=List5&gender='.$title.'&firstname='.$first.'&lastname='.$last.'&email='.$email.'&dob='.$dob); 
    Also, you may want to urlencode those parameters.

    PHP Code:
    $iframecontent get_url(
      
    sprintf(
        
    'http://domain.com/data.ashx?id=270.126&sub_id=List5&gender=%s&firstname=%s&lastname=%s&email=%s&dob=%s',
        
    urlencode($title), 
        
    urlencode($first),
        
    urlencode($last),
        
    urlencode($email),
        
    urlencode($dob)
      )
    ); 

    (in the highlighted version you posted the string is all red, while the variables ~should~ be blue, that's always a good clue to see you've screwed up the string )
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much ScallioXTX
    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
  •