Well, let's take it one thing at a time. The first issue is a scope issue. $Content is not global! That said, when you try to echo $Content, the variable, as far as PHP is concerned doesn't exist.
If that sounds confusion, check out the link below.
http://www.php.net/manual/en/language.v ... .scope.php
Moving forward: the function create_file() is not aware of $Content because it's not passed to it in the argument list and it's not made global. Now don't mistake that as you are required to do both of the previous, you are not. You can do one of three things.
a) pass it by like this:
Code: Select all
function create_file($Content, $file)
{ /* function stuff */ }
b) or:
Code: Select all
function create_file($file)
{
global $Content;
/* function stuff */
}
c) and:
Code: Select all
function create_file($file)
{
/* function stuff */
fputs($fp, $GLOBALS['Content']);
/* function stuff */
}
I would do it like this:
Code: Select all
function create_file($string, $file)
{
$fp = fopen($file, "a"); //open file
if(!$fp)
{ return false; }
fputs($fp, $Content);
fclose($fp); //close file
}
# close function
The perhaps use it as such.
Code: Select all
$Content='Thanx for the ride lady!';
$file='c:\toerag\free_stuff_for_bdkr.html';
create_file(&$Content, $file);
Now in your script, echo'ing $Content will not help you determine that things ran with success. Just go to where the file should be on your disk and see if it's there. You could also use file_exists(). It's all in the manual.
Turn your error_reporting all the way up too. Use error_reporint(E_ALL) while testing.
Hope this helps. I know it may seem like confusing theory mumbo jumbo, but it'll help in teh long run.
On another note, I remeber Toerag from a Douglas Adams book. Is that where you came up with the name? Cool stuff. Do you guys do custom printing?
Cheers,
BDKR