So, I've got this file name that I got some PHP to produce - $id
And now what I would like to do is for it to generate a file with $id as it's filename as well as open it. I've been trying to get this to work...
$fp = fopen("filename.xml", "a");
But if I do this:
$fp = fopen("$id.xml", "a"); or even use the "print" function - the quotes stop the PHP from working and just give it the filename "print blah blah blah" or "$id, etc".
The reason I would like this to work is that I would like every file generated to have unique filename. I'm a newbie with PHP so if I'm going down the wrong track - would you mind pushing me in the right direction please?
Thanks.x
Ah, that's an idea. I've tried it and it didn't seem to like it much. ^^ Never thought to use the && though.
At the moment, I've managed upto this:
$fp = fopen(print "$uid.$xtn", "a");
and
$fp = fopen("$uid.$xtn", "a");
Where $uid is the id I was on about before and $xtn is the file extension. It's creating a file but all it's doing is naming it "1" and putting the requested info into it.
Solved.
I ditched the $uid as I had my doubts of it working and went for the random approach. I then took Tasm's advice about the full stop. Thanks everyone. ^^
$ran = rand (1, 1000000) ;
$fp = fopen($ran. ".xml", "a");
And now what I would like to do is for it to generate a file with $id as it's filename as well as open it. I've been trying to get this to work...
$fp = fopen("filename.xml", "a");
But if I do this:
$fp = fopen("$id.xml", "a"); or even use the "print" function - the quotes stop the PHP from working and just give it the filename "print blah blah blah" or "$id, etc".
The reason I would like this to work is that I would like every file generated to have unique filename. I'm a newbie with PHP so if I'm going down the wrong track - would you mind pushing me in the right direction please?

Thanks.x
Ah, that's an idea. I've tried it and it didn't seem to like it much. ^^ Never thought to use the && though.
At the moment, I've managed upto this:
$fp = fopen(print "$uid.$xtn", "a");
and
$fp = fopen("$uid.$xtn", "a");
Where $uid is the id I was on about before and $xtn is the file extension. It's creating a file but all it's doing is naming it "1" and putting the requested info into it.
Solved.

$ran = rand (1, 1000000) ;
$fp = fopen($ran. ".xml", "a");