Jump to content

Php Url Variable Help


ApocalypeX

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...