Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy content of a PHP/mySQL page

Status
Not open for further replies.

bradoirs

Technical User
Jul 8, 2009
35
GB
For reasons too complicated to explain I would like to read the contents of a page generated "on the fly" using PHP with mySQL to save as an archive file. Simple code:

$url='blanca.html';
$str = file_get_contents($url);
echo $str;

works great with standard HTML files but

$url='mypage.php?myref=66';
$str = file_get_contents($url);
echo $str;

just brings up blank page.

Well out of my depth here so be kind with your comments and very simple with your help

Alternatively is there a simple way of making the PHP page save automatically?

 
with the first code snip you are taking the raw html from the FILE SYSTEM. not from the webserver.

to get the rendered content from the WEB SERVER, you need to use the complete uri including protocol.

Code:
$url = '[URL unfurl="true"]http://www.mydomain.com/page.php?var=val&var2=val2'[/URL]
$content = mysql_real_escape_string(file_get_content($url));
//write $content to database field.
 
The answers when you get them are always so simple but very gratefully received. Once again thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top