LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-31-2004, 10:39 AM   #1
canzi
LQ Newbie
 
Registered: Jan 2004
Posts: 8

Rep: Reputation: 0
Unhappy Redhat9 and PHP


Problem : my PHP scripts will not save form data to a text file

Information : well there not actuall my scripts but i have tried at least 6 different ones now, some are very simple, PHP seems to work ok, but when data needs to be saved to a text file i.e. simple chat program or address logging, the file remains empty, if i manually enter data into this file it can be recalled and viewed, i have chmod 777 all needed files and given permission to the user 'apache'

is there something in Apache that is stopping the data save?
what is needed for even the simplest PHP script to write to a text file??

thanks in advance
 
Old 02-07-2004, 11:33 PM   #2
canzi
LQ Newbie
 
Registered: Jan 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Thumbs up canzi

id just like to add that i used this script to test my php and it works, both read and write, ill have a closer look at the otherscripts to find the problem
*****************************************************


<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}
?>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
cant compile php-4.3.4 in redhat9 demmylls Linux - General 1 02-09-2004 01:37 PM
From RedHat9 to FreeBSD (Apache 2 & Mysql & PHP 4) guardian653 *BSD 5 12-11-2003 05:31 PM
Updating php 4.3.1 from tar and keeping current php configuration with mandrake 9.1 mrjeep Linux - General 0 04-02-2003 07:50 AM


All times are GMT -5. The time now is 03:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration