tags:

views:

52

answers:

3

Hi I'm using the following code: to write contents from one file to another

 $page = file_get_contents('myPage.php?id='.$_GET['id']);
 $file = 'temp/form_'.$_GET['id'].'.html';
 file_put_contents($page, $file);

But I keep getting the following errors

 Warning: file_get_contents(myPage.php?id=9) [function.file-get-contents]: 
 Invalid argument in C:\Program Files\etc\etc..

and

 Warning: file_put_contents() [function.file-put-contents]: Filename 
 Filename cannot be empty in C:\Program Files\etc\etc..

Anyone know what could cause these errors

thanks

rifki

A: 

Hi, I think that you try to read the content of page 'myPage.php?id='.$_GET['id'] and write it to a html file. Then try this:

$page = file_get_contents($your_domain . $slash_if_necessary . 'myPage.php?id='.$_GET['id']);
 $file = 'temp/form_'.$_GET['id'].'.html';
 file_put_contents($page, $file);
Bang Dao
+1  A: 

You have the arguments backwards for file_put_contents. Try switching them as follows:

file_put_contents($file, $page);

Edit:

Change your variable declaration to in order to resolve the first error:

$page = include 'myPage.php';
Joseph
Thanks that fixed the 2nd error, but still have the first one stating i have an invalid argument, any ideas?
Rifki
`file_get_contents` reads in the file as a string, and does not process it as PHP. Try using an include instead. Editing my response to add in the additional code.
Joseph
A: 

Give the full path with Http://

Motyar