PHP - Gestbook.... help - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: PHP - Gestbook.... help (/showthread.php?tid=75470) PHP - Gestbook.... help by distorted on 06-19-2007 at 05:29 PM
Ok i'm trying to work on a script where my friends (who have photo's on there photobucket accounts etc....) can upload the img url to my form and it adds it to a flattext file, basicly its a modifyed guestbook, but i have little/no knowladge of PHP, i have got this to work in some shape or form, but whats making me struggle is i cant get the new entrys to go to the top of the page instead of being added to the bottom. i know its not possable to write to the top of a flat text, and the way to do this would be to get it to open the existing content from the file and then add that to the end of the new entry, and write it all in at once....? but i dont know how... any suggestions. heres my code: RE: PHP - Gestbook.... help by absorbation on 06-19-2007 at 07:56 PM What's in config.php and where are your forms located ? RE: PHP - Gestbook.... help by Baggins on 06-19-2007 at 08:22 PM
There is nothing in the script that is not defined there, I am guessing config.php is empty. RE: PHP - Gestbook.... help by roflmao456 on 06-19-2007 at 08:23 PM
code: will add the new entry on top of the new ones? RE: PHP - Gestbook.... help by Baggins on 06-19-2007 at 08:39 PM
code: This does exactly what roflmao's does, except it is safe from PHP and HTML injection, and allows for basic tags such as <b><i><u> and <a> in the message field. I figure this method, opening the file for read/write, will be more efficent than filegetcontents() because you only need to open it once. RE: PHP - Gestbook.... help by distorted on 06-20-2007 at 09:44 AM Thankyou all for your prompt replys. i will try the suggested ways and see which works for me and yes config.php is empty, not to sure why its there either, was just in the tutorial i used to make it. thanks again x RE: PHP - Gestbook.... help by distorted on 06-20-2007 at 10:06 AM
For some reason Baggins when i use your script it sort of works (as in new entrys go to the top) but for some reason it dosent overwrite the existing entrys it just adds the new one with the old ones again, for exaple when i upload twice i have 3 images, as the second time it adds the new image to the old and then places the new and old image behind the old one alredy there. so it goes. RE: PHP - Gestbook.... help by WDZ on 06-21-2007 at 02:10 AM
quote:What PHP version are you running? It must be ancient (2002 or earlier) if it doesn't have file_get_contents()... To check the version, you can use phpinfo(). If you want to fix the code Baggins posted, adding this line right before the first "fwrite" line should do the trick... code: RE: PHP - Gestbook.... help by distorted on 06-21-2007 at 07:00 AM Thankyou so much WDZ your a life saver it now works perfectly. i'm running PHPTRIAD to test scripts so i presume it is rather acccent. thanks again. x |