Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 502
0 Users 26 Guests Online
Forum Index » PHP + MySQL » FOpen?
Posted on Sunday 20th May 2007 at 06:24 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Hey, I want Fopen to create a file using the type 'x'. Heres what I got so far:
PHP Code
1
2
fopen('url' 'x');


How can I make the file name be random. I know that I should use a randomizer, but how do I set the name?

Does anybody know, thanks!
Posted on Sunday 20th May 2007 at 07:56 PM
DanielXP
avatars/1.png's Avatar
Senior Member
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
<?
//Random number alpha (Letters + Numbers)
$alphanum  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//Make the random name
$filename substr(str_shuffle($alphanum), 05); 
//Set as w for open for writing only
$new_file fopen("$filename""w");
//Stuff you want to go into the file
$input 'Some stuff you want in the file goes here..';
fputs($new_file$input);
fclose($new_file);
?>


That makes a random name and saves it as a file
Posted on Sunday 20th May 2007 at 08:46 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
PHP Code
1
2
3
4
5
6
7
8
9
10
//Random number alpha (Letters + Numbers)
$alphanum  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//Make the random name
$filename = substr(str_shuffle($alphanum), 0, 5); 
//Set as w for open for writing only
$new_file = fopen("http://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/$filename", "w");
//Stuff you want to go into the file
$input = 'Some stuff you want in the file goes here..';
fputs($new_file, $input);
fclose($new_file);


I added that. I want to create the file into here:
Code
http://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/


And I get this error with the code above:

Code
Warning: fopen(http://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/90fat) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 62

Warning: fputs(): supplied argument is not a valid stream resource in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 65

Warning: fclose(): supplied argument is not a valid stream resource in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 66



Help :(!
Posted on Sunday 20th May 2007 at 09:10 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
CHMOD the file to 777 lol. it has no write permissions
Posted on Sunday 20th May 2007 at 10:37 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I CHMODed the file to 777 (shop.php). Same error..

Note:

Code
Warning: fopen(http://24.36.122.119/forbidden/habbo/habs/habs/database/vouchers/MSF7Q) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/diablosb/domains/hotelmario.info/public_html/members/shop.php on line 62


Its trying to open that file, when there is no file. I want it to create the file with a random name, and then put a variable called $gm.

Any ideas?
Posted on Sunday 20th May 2007 at 10:52 PM
DanielXP
avatars/1.png's Avatar
Senior Member
Try getting rid of the full URL.

PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
<?
//Random number alpha (Letters + Numbers)
$alphanum  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//Make the random name
$filename substr(str_shuffle($alphanum), 05); 
//Set as w for open for writing only
$new_file fopen("forbidden/habbo/habs/habs/database/vouchers/$filename""w");
//Stuff you want to go into the file
$input 'Some stuff you want in the file goes here..';
fputs($new_file$input);
fclose($new_file);
?>
Posted on Sunday 20th May 2007 at 10:58 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I cannot remove the forum post because I am putting this code on frihost, but the server IP is on my computer.
:S.
Posted on Monday 21st May 2007 at 11:05 AM
DanielXP
avatars/1.png's Avatar
Senior Member
Host the script on your xammp host then.
Posted on Monday 21st May 2007 at 02:06 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Now thats an Idea !!! :P - Thanks!