Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,043 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,517 people online right now. Registration is fast and FREE... Join Now!




Writing To Files

 
Reply to this topicStart new topic

Writing To Files, will this work?

Koenie
17 Nov, 2002 - 12:06 PM
Post #1

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

I've made this script and I just wanted it to get checked before I fuck up my total internet domain. Will this work? It should add a simple string to the end of a file and change the content of another file (increment the number that the file contains).

CODE

<?

$fstring = "This is just a string.";

$fnum_1 = include("http://twizzle.koeniedesign.com/counter.txt"); // counter.txt is a file with a number used for other purposes.
$fnum_2 = intval($fnum1) + 1;

$fo_1 = fopen("http://twizzle.koeniedesign.com/comlib.js/", "a"); // comlib.js is a file that stores all the strings
$fw_1 = fwrite($fo_1, $fstring);
fclose($fo_1);
 
$fo_2 = fopen("http://twizzle.koeniedesign.com/counter.txt/", "w");
$fw_2 = fwrite($fo_2, $fnum_2);
fclose($fo_2);

?>


Koenie
User is offlineProfile CardPM
+Quote Post

Spider
RE: Writing To Files
18 Nov, 2002 - 11:12 AM
Post #2

Arachnid
****

Joined: 10 Jul, 2002
Posts: 769


My Contributions
a little advice koenie smile.gif

if you want to know if something works, it's best to test it.

If you don't want to test it on your important stuff, either make a straight copy of it, or just make some new smaller files to test it on. I don't see anything wrong with the code, but you never know, it's easy to miss stuff out.
User is offlineProfile CardPM
+Quote Post

Koenie
RE: Writing To Files
18 Nov, 2002 - 11:36 AM
Post #3

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

OK, I did test, and I got a BUNCH of warnings and stuff.....

It didn't work....

Koenie
User is offlineProfile CardPM
+Quote Post

fyrestorm
RE: Writing To Files
18 Nov, 2002 - 11:45 AM
Post #4

D.I.C Lover
Group Icon

Joined: 4 Apr, 2002
Posts: 3,103



Thanked: 2 times
Dream Kudos: 228
My Contributions
use the absolute address rather than the relative
User is offlineProfile CardPM
+Quote Post

Koenie
RE: Writing To Files
18 Nov, 2002 - 12:27 PM
Post #5

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

QUOTE(fyrestorm @ Nov 18 2002, 09:45 PM)
use the absolute address rather than the relative

Waddayamean?
User is offlineProfile CardPM
+Quote Post

Antisoft
RE: Writing To Files
19 Nov, 2002 - 04:11 AM
Post #6

D.I.C Head
**

Joined: 20 Jun, 2002
Posts: 71

Perhaps instead of http://blabla.com u should use /home/html/counter.txt... it's more safe and more reliable to work.
User is offlineProfile CardPM
+Quote Post

Koenie
RE: Writing To Files
19 Nov, 2002 - 04:16 AM
Post #7

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

how can i get this adress?
User is offlineProfile CardPM
+Quote Post

capty99
RE: Writing To Files
19 Nov, 2002 - 04:29 AM
Post #8

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,161



Thanked: 16 times
Dream Kudos: 550
My Contributions
well i dont know what they are talking about. you are using the absolute address...

absolute :

say i was linking from my capty99.com index and i wanted to open something in a folder named fish and open a file called fish.html
something like
<a href="http://www.capty99.com/fish/fish.html">fish.html</a>

thats how it would look right?

well a relative would be
<a href="/fish/fish.html">fish.html</a>

it just looks for a fish folder and a fish.html from wherever you have the page containing the link. you just have to be more careful with your file placement then.

but you have that correct and fyrestorm screwed up somewhere in his post.
User is offlineProfile CardPM
+Quote Post

Koenie
RE: Writing To Files
19 Nov, 2002 - 05:15 AM
Post #9

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

But about the writing to files thingy.....

Do I have to CHMOD the files I wanna write to?
User is offlineProfile CardPM
+Quote Post

Spider
RE: Writing To Files
19 Nov, 2002 - 06:50 AM
Post #10

Arachnid
****

Joined: 10 Jul, 2002
Posts: 769


My Contributions
yes, you need to chmod the files you want to write too.

also, I noticed this:

twizzle.koeniedesign.com/comlib.js/

is that last backslash meant to be there?

you have one on two of the links.
User is offlineProfile CardPM
+Quote Post

Koenie
RE: Writing To Files
19 Nov, 2002 - 06:55 AM
Post #11

What?!
*****

Joined: 8 Jul, 2002
Posts: 1,313

I sort of copied it from my PHP book.....

What about the CHMODing then?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 04:49PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month