Jump to content

Php Url Variable Help


ApocalypeX
 Share

Recommended Posts

Using the "PHP Simple HTML DOM Parser" - PHP Simple HTML DOM ParserI'm learning PHP and I wanted to write a page that gets text from a certain webpage and prints it.Now when I write this:

<?phpinclude('simple_html_dom.php');$html = file_get_html('http://www.bungie.net/Account/Profile.aspx?memberID=1');foreach($html->find('span#ctl00_mainContent_header_lblUsername') as $e) print $e->innertext . '<br>';?>

It works perfectly displaying what I want it to.But when I to make the URL a variable it fails:

<?phpinclude('simple_html_dom.php');$theurl = "'http://www.bungie.net/Account/Profile.aspx?memberID=1'";$html = file_get_html($theurl);foreach($html->find('span#ctl00_mainContent_header_lblUsername') as $e) print $e->innertext . '<br>';?>

Anyone know a way around this?

Link to comment
Share on other sites

Veen's first response was correct, you shouldn't have the single quotes inside double quotes like that (or else it will try to find 'http:// ... ID=1' instead of http:// ... ID=1). What does your code look like now?

Link to comment
Share on other sites

Veen's first response was correct, you shouldn't have the single quotes inside double quotes like that (or else it will try to find 'http:// ... ID=1' instead of http:// ... ID=1). What does your code look like now?
I've fixed the problem thanks guys :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...