Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> A Few Things [php Fread, Fwrite]
robocz033
post May 13 2007, 10:46 PM
Post #1


Premium Member
********

Group: Members
Posts: 165
Joined: 28-April 07
From: Where ever i feel appropriate
Member No.: 42,321



i am trying to learn fread, fwrite, and $_get for my form generator. this is my basic need:
a php script that will check a file named numbers.txt, read the information, input it into the file and erase the stuff in numbers.txt and replace it with a number 1 higher starting from 0.
since i have the fwrite script, that is fine, but to describe the whole thing, i need a script that will check numbers.txt, then use that number in a url (for posting a reply on a dedicated forum) so when a user presses post, it uses that url, instead of the same one. so after it gets the number, that number must be deleted from numbers.txt then replaced with 1 number higher.

So i guess it would go like this:
The url will have a php script, but i am not sure which one, i am guessing $_get that will retrieve a temporary number from numbers.txt and use that in a url.
Then when they hit post/submit, a script will erase numbers.txt and add a number that was 1 higher than the previous one.

I either need a full script or just some guidance. =)

Or another option is almost the same thing, but a script will check the database (i am not sure, but i think the post count would be there) for the post count, add one to it, and insert that temporarily into the url. i am not sure how possible that would be. but it would be nice not to upload another forum.

So this way would entitle:
A script within the url that will temporarily insert the post count plus one so the post is valid. (by post count, i mean the number of topics created). that pretty much sums up what would be needed. although i am not sure it is possible seeing as it would need to contact the database and find the total number of topics.

If it is any help, i use smf. i can also allow anyone who can help to use an administrator account on the forum to look at server information and stuff.

This post has been edited by jlhaslip: May 19 2007, 04:23 PM
Go to the top of the page
 
+Quote Post
truefusion
post May 14 2007, 01:59 PM
Post #2


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,893
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



The part about writing to a file and retrieving the information for later use and modifying the information is easy. The hard part is getting the forum script to work with it. I don't know my way around the SMF scripting or any other forum scripting. If having the forum script work with your script is a necessity, then i would suggest posting this in the support forum on the site of the makers of the forum.
Go to the top of the page
 
+Quote Post
galexcd
post May 15 2007, 12:56 AM
Post #3


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,018
Joined: 25-September 05
From: L.A.
Member No.: 12,251



If you're using SQL to store the posts, there is a much easier way. The field you are using to hold the ID of the post, just make that an index, and set auto-increment. This way, sql will do all that work for you. Are you programing your own forums? If you are, PM me and i could give you some guidance on how the best way is to lay out all the tables, and how to have them work. Also, if you don't have an ID field, or i misunderstood you somehow, you could always get the total number of posts by
CODE
mysql_numrows($result);

where the variable result is the query of the table you are working with. I hope this helps, if not just reply here and i'll try to come up with a better answer. If you have any code already written that would be a help too. biggrin.gif
Go to the top of the page
 
+Quote Post
robocz033
post May 15 2007, 02:10 AM
Post #4


Premium Member
********

Group: Members
Posts: 165
Joined: 28-April 07
From: Where ever i feel appropriate
Member No.: 42,321



well, i dont really understand what you said. however, i am not scripting my own forum, i use smf (i believe i mentioned that) but if you have any messenger, i can talk to you about it on wednesday because i am not going to be home at all tomorrow.
Go to the top of the page
 
+Quote Post
galexcd
post May 15 2007, 03:01 AM
Post #5


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,018
Joined: 25-September 05
From: L.A.
Member No.: 12,251



Yes, well my AIM is in my profile and my msn uses my primary email so i'll pm you with that if you want.
Go to the top of the page
 
+Quote Post
hitmanblood
post May 18 2007, 07:49 PM
Post #6


Privileged Member
*********

Group: [HOSTED]
Posts: 792
Joined: 13-April 07
From: mreža
Member No.: 41,558



QUOTE(robocz033 @ May 14 2007, 12:46 AM) *
i am trying to learn fread, fwrite, and $_get for my form generator. this is my basic need:
a php script that will check a file named numbers.txt, read the information, input it into the file and erase the stuff in numbers.txt and replace it with a number 1 higher starting from 0.
since i have the fwrite script, that is fine, but to describe the whole thing, i need a script that will check numbers.txt, then use that number in a url (for posting a reply on a dedicated forum) so when a user presses post, it uses that url, instead of the same one. so after it gets the number, that number must be deleted from numbers.txt then replaced with 1 number higher.
So i guess it would go like this:
The url will have a php script, but i am not sure which one, i am guessing $_get that will retrieve a temporary number from numbers.txt and use that in a url.
Then when they hit post/submit, a script will erase numbers.txt and add a number that was 1 higher than the previous one.
I either need a full script or just some guidance. =)
Or another option is almost the same thing, but a script will check the database (i am not sure, but i think the post count would be there) for the post count, add one to it, and insert that temporarily into the url. i am not sure how possible that would be. but it would be nice not to upload another forum.
So this way would entitle:
A script within the url that will temporarily insert the post count plus one so the post is valid. (by post count, i mean the number of topics created). that pretty much sums up what would be needed. although i am not sure it is possible seeing as it would need to contact the database and find the total number of topics.
If it is any help, i use smf. i can also allow anyone who can help to use an administrator account on the forum to look at server information and stuff.


I am just interested if you have done or solved this problem because noone of you two haven't wrote anything after.

If you have solved this problem I will be glad to help you also.
Go to the top of the page
 
+Quote Post
robocz033
post May 18 2007, 10:28 PM
Post #7


Premium Member
********

Group: Members
Posts: 165
Joined: 28-April 07
From: Where ever i feel appropriate
Member No.: 42,321



i am currently working on it with alex and ghostrider
Go to the top of the page
 
+Quote Post
slushpuppy
post May 19 2007, 01:59 AM
Post #8


Newbie [Level 2]
**

Group: Members
Posts: 29
Joined: 7-September 06
Member No.: 29,569



If your reading from a text file and wish to replace the current number with a number higher than it, use file(). Upon saving the results to an array, you can use array_map or other methods to increase that number. Following that, fopen(FILE NAME,w) will erase the contents and you can insert the new value into the file with fwrite.
Links
http://sg.php.net/manual/en/function.fopen.php
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics