Click to See Complete Forum and Search --> : PHP Scriptors
dniezby
04-25-2003, 10:11 PM
I have designed a website for someone that has static information boxes that can be updated through a user update interface. The problem I'm having is remembering how to write the PHP script. Here is what I have if someone can help.
// Variable $update is the receiving variable from the update
// form.
$update=fopen("./infobox1.txt","w+"); //open the txt file
fwrite($update); //write the contents to txt file
fclose($update); //close the file
echo "&infobox1=$update"; // output the file's information
I know I'm missing something.
blanius
04-26-2003, 01:26 PM
looks ok, hard to say what the problem is you didn't state what the error was.
Oh and Now that I think about it The way we do this is to simple INCLUDE the file
dniezby
04-27-2003, 12:57 AM
Maybe I need to explain this better.
A user will open a webform for the specific box they want to update.
They enter the information into the webform and it get's sent to the .txt file.
The website will open as normal and each of the info boxes will load the information from the appropriate .txt files and post to the website.
The reason behind this is, I want the my client to be able to update the information on the website with ease and not really need access to my server directly unless I really have to.
I've gone over the code a hundred times and I can't figure out why it's not writing to the file.
fopen("text.txt","w+"); is supposed to open the file, delete the contents and place the cursor at the beginning. Also, the w+ mode is supposed to create the file IF it doesn't exist.
Maybe it's the CHMOD? IF that IS the problem, I host my own websites. How the hell do I CHMOD a file on my own server if all I have to do is copy a file to a directory as opposed to uploading it to the server???
MalteG
04-27-2003, 07:13 AM
Try this:
$myfile=fopen("./infobox1.txt","w+"); //open the txt file
fwrite($myfile, $update); //write the contents to txt file
fclose($myfile); //close the file
echo "&infobox1=$update"; // output the file's information
As $update is the text you want to write to a file
you can't use it as a file handle.
BTW you don't have to change the rights of a PHP script.
It doesn't need execution rights.
blanius
04-27-2003, 03:34 PM
Originally posted by MalteG
Try this:
$myfile=fopen("./infobox1.txt","w+"); //open the txt file
fwrite($myfile, $update); //write the contents to txt file
fclose($myfile); //close the file
echo "&infobox1=$update"; // output the file's information
As $update is the text you want to write to a file
you can't use it as a file handle.
BTW you don't have to change the rights of a PHP script.
It doesn't need execution rights.
I does need write permissions though.. Esp on a Win Server. I don't know how you'd set it though depends I suppose on the what server you are using. Check the Server docs.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.