robocz033 0 Report post Posted May 13, 2007 (edited) 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. Edited May 19, 2007 by jlhaslip (see edit history) Share this post Link to post Share on other sites
truefusion 3 Report post Posted May 14, 2007 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. Share this post Link to post Share on other sites
galexcd 0 Report post Posted May 15, 2007 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 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. Share this post Link to post Share on other sites
robocz033 0 Report post Posted May 15, 2007 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. Share this post Link to post Share on other sites
galexcd 0 Report post Posted May 15, 2007 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. Share this post Link to post Share on other sites
hitmanblood 0 Report post Posted May 18, 2007 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. Share this post Link to post Share on other sites
robocz033 0 Report post Posted May 18, 2007 i am currently working on it with alex and ghostrider Share this post Link to post Share on other sites
slushpuppy 0 Report post Posted May 19, 2007 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.Linkshttp://sg.php.net/manual/en/function.fopen.php Share this post Link to post Share on other sites