ApocalypeX Posted January 8, 2010 Share Posted January 8, 2010 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 More sharing options...
mvsveena Posted January 8, 2010 Share Posted January 8, 2010 Hi,Am not sure but try this please.$theurl = "http://www.bungie.net/Account/Profile.aspx?memberID=1";-Veen Link to comment Share on other sites More sharing options...
ApocalypeX Posted January 9, 2010 Author Share Posted January 9, 2010 Nope doesn't work. Any other ideas? Link to comment Share on other sites More sharing options...
mvsveena Posted January 9, 2010 Share Posted January 9, 2010 I think you can echo the variable $theurl and check whether it prints the URL properly... -Veen Link to comment Share on other sites More sharing options...
Synook Posted January 9, 2010 Share Posted January 9, 2010 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 More sharing options...
ApocalypeX Posted January 10, 2010 Author Share Posted January 10, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.