PDA

View Full Version : Unable To Save Info To File ?


Slumpack
05-26-2004, 07:03 AM
This is what i have, what it does is saving a bunch of text from a textbox into .txt file but for some reason it doesn't work !!
i tried and it work on my local machine and it work on my other webserver (with PHP 4.3.6 -- all of the server) could it be the PHP configuration ?

<?
$vars = array('ref', 'body');
$varstr = '';
foreach ($vars as $var) {
if(isset($_POST[$var]))
{
*$vvar=$_POST[$var];
*$$var= $vvar;
}
}

if(!isset($ref) or !isset($body) or !file_exists('../'.$ref)) die('fail');


if(substr($ref,-1)!='/') {
$path_parts = pathinfo($ref);
$dir=$path_parts["dirname"];
$file=$path_parts["basename"];
$dfile='../'.$dir.'/descr.txt';
}
else {
$dir=$ref;
$file='__dir';
$dfile='../'.$dir.'descr.txt';
}


if($lines = @file($dfile)) {
foreach($lines as $str) {
* *list($key,$var)= explode("\t", $str);
* *$data[$key]=rtrim($var,"\r\n");
}
}
*$data [$file]=urlencode(stripslashes($body));
*asort($data);
*if($fp=@fopen($dfile,'w')){
* foreach($data as $key=>$val) {
* *if($val!='') fputs($fp,$key."\t".$val."\r\n") or die('fail');
* }
* echo ('Save was successfull');
*} else echo ("Error: Can't create file");

?>

Thanks

dbmasters
05-26-2004, 08:38 AM
have you CHMOD'd the file to 777 so it's writable?

Also, "$$var" as a variable might be creating problems, not sure tho.

Slumpack
05-26-2004, 01:10 PM
Yes the directory is CHMOD 777 | The weird part is that it work at 2 other different server ?? just this server that having a problem ?? could it be server side configuration or something ??

The only issue i can think of is the "File Ownership" !! any other suggestion ?

I need to change ownership of the directory that i'm saving the files to to apache
cause the server needs ownership to save the files. Maybe admin could do something ? or maybe i'm wrong :P

Thanks.

Slumpack
05-27-2004, 01:18 PM
I Confirm the issue with Apache 1.3.*

Click Here (http://www.directadmin.com/forum/showthread.php?threadid=3148)