Closed Thread Icon

Topic awaiting preservation: PHP fputs/fwrite quotes difference? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12279" title="Pages that link to Topic awaiting preservation: PHP fputs/fwrite quotes difference? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP fputs/fwrite quotes difference? <span class="small">(Page 1 of 1)</span>\

 
warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 06-23-2002 01:55

PHP script #1 -
I want this script. For some reason it just won't write to file. It's written to file twice, and even then it was incomplete. I did have some initial problems getting this script to find the files. I am no longer getting fopen errors, so it looks like it's finding the files just fine - it's just not writing. (Later I'll ask about the finding files thing.)

PHP script #2 -
I don't want this script, but I installed it just to see. It writes to file beautifully.


Been banging my head for several hours. CHMOD is not the problem. So, with my very limited knowledge of PHP, I started doing side-by-side comparisons of the code.

Script #1 using fputs($file, $whatever). That's it.

Script #2 uses fwrite($file, $whatever) and in quite a few place fwrite($file, "$whatever").

I read that fputs and fwrite are identical. So I am curious about the use of quotes in script #2. Normally I would go through and add all the quotes to #1, but the use of quotes in #2 is not consistant.

I'm pretty sure that's my problem. Why the quotes in some instances of fwrite and not in others?

I did do some poking around with server things and PHP versions. This all looks koesher to me.


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-23-2002 02:06

umm got the scripts?

you shouldn't need the quotes.
The fwrite thing is fairly basic I would guess the issue may be with your fopen statement you want to make sure you are using the correct mode in the fopen (pretty much any mode except "r" should work "a" or "a+" are the best for debugging since they will create the files if they don't exist).

but really need to see the scripts to debug for ya.
(If they're long links would be fine)



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 06-23-2002).]

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 06-23-2002 21:39

Sorry I took so long. Got side-tracked, don't ya know.

The script that I want is actually two scripts.

guestbook_mainpage.txt

guestbook.txt

In the first one, guestbook_mainpage.txt, there some problems with finding files. In lines 10 & 11, it can't find archive_file.txt unless I use absolute paths. I also have to take the $ out before the filename. There are a few other places where I have to take out the $ before the filename.

I'm pretty sure that guestbook.txt is suppossed to do all the writing to file. Well, t's not writing and I'm not getting any fopen errors.

Mucho appreciate any help. I hope it's something simple.

edit: BTW, those two files are the unmodified versions.



[This message has been edited by warjournal (edited 06-23-2002).]

Xdreamer.ch
Maniac (V) Inmate

From: Switzerland
Insane since: Mar 2001

posted posted 06-23-2002 23:34

you could even write instead of

code:
if (!file_exists("files/archive/$archive_file.txt")){
$file = fopen("files/archive/$archive_file.txt","w");
fclose($file);



this one

code:
$file = fopen("files/archive/archive_file.txt", "w") OR DIE ("File doesn't exist")



and btw. why are you writing $archive_file.txt? You can write it so:

code:
$txt ="archive_file.txt";
$file = fopen("files/archive/$txt", "w") OR DIE ("File $txt doesn't exist")



cu
~Xdreamer.ch~

warjournal
Maniac (V) Mad Scientist

From:
Insane since: Aug 2000

posted posted 06-26-2002 18:13

Thank, Dreamer.

Any idea why it's not writing to file?


« BackwardsOnwards »

Show Forum Drop Down Menu