Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 24th, 2004, 01:09 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ScottG
Default Question about fopen

First off, thank you for hosting this wonderful forum. I've just found this site, and it was bookmarked immediately. You rule!

Admittedly, I am very new to php (which is why i'm in the beginners forum) so this might be something real easy I'm missing. Anyway, I'm trying to get a file to open using fopen only it's not working. The code I've tried is:
Code:
$op = fopen("./text.txt", "w+");
  if(!$op) die ("Cannot open file");


I always get the error. I've tried using fully qualifed paths too, as well as a fully qualified url as a path, nothing seems to work. What are some reasons that fopen wouldn't open a file?
Reply With Quote
  #2 (permalink)  
Old November 24th, 2004, 03:10 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hey there,

What operating system are you running on? I suggest you read Rich's FAQ on setting file permissions. It's located in the PHP FAQ forum.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote
  #3 (permalink)  
Old November 24th, 2004, 03:24 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ScottG
Default

Quote:
quote:Originally posted by Snib
What operating system are you running on?
The server is UNIX, but the machine I'm actually doing the coding on is a windows box. I'm on my way to that faq now. Thanks.

-Scott

this is not the .sig you are looking for.
Reply With Quote
  #4 (permalink)  
Old November 24th, 2004, 03:56 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ScottG
Default

well, I checked it out, and I think I must be doing something wrong. The man entry for chown on my system says I should use this syntax: chown -R username[:www] file, but I keep getting errors. If I specify a filename, or even just *.php, it tells me "No match". If I just use a wildcard, I get "Unknown user ID (first filename or dir in list)."

So, I tried setting everything to 777 (not very desireable) and that didn't work either. I was able to set the permissions, but the file still doesn't open. I also tried the first suggestion about files on my networked windows box, but no dice there either. Is it possible that there's some server restriction preventing the usage of fopen? If so, would a phpinfo() tell me?

Thanks again for looking at this. You are the first person to even answer the question on any forum I've been to.

-Scott

Edit: I found this... allow_url_fopen is set to 1. Dunno if that's what I'm looking for or not.

this is not the .sig you are looking for.
Reply With Quote
  #5 (permalink)  
Old November 24th, 2004, 04:14 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ScottG
Default

Okay, I was reading the entry for fopen over at zend.com, and they say that if safe_mode is set on the server, then I could be subject to "more restrictions". They don't say what those restrictions are, but I suspect this is where my problem lies.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
yes or no question grstad Classic ASP Databases 0 April 14th, 2006 04:37 AM
fopen permission denied PPGpilot Beginning PHP 1 February 24th, 2006 03:56 PM
Problem with fopen() Dave Brown Beginning PHP 0 February 23rd, 2005 09:24 PM
Passing a URL to fopen() dadio PHP How-To 4 April 6th, 2004 06:58 PM



All times are GMT -4. The time now is 01:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.