Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

fopen() Error

I am trying to use the fopen() function to create a file, but I keep getting this error:

Warning: fopen(test.php) [function.fopen]: failed to open stream: Permission denied in /home/a3150657/public_html/admin.php on line 87

That part of the code looks like this:

Code:
<?php
$name = $_POST['name'];
$file = fopen($name,'x');
?>

The post info is "test.php".

Any idea why I'm getting that error and how I can fix it?  Thanks in advance for the help.
 

___

Sponsor

Change the file permissions on the file in question and see what happens. I think you would also get that result if the file did not exist.
 
The file doesn't exist.  I'm trying to create the file with the fopen() function.  I managed to change the permissions on my public_html folder, and now it seems to work.  The only problem remaining is that my host won't let me edit files created by the fopen() function.
 

___

Sponsor

Yeah that's because PHP creates and accesses as a system user rather than as your user, you need to make sure you set the file permissions on any file you create.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top