Page 2 of 2

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 9:18 am
by Damian2020
Notice: Undefined index: company_body ... on line 9

Warning: fopen(777) [function.fopen]: failed to open stream: Permission denied ... on line 11

can't open file

Lol same thing. Chmoding? Maybe I misunderstood?

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 9:22 am
by jackpf
No, chmod the file to 777. Are you on windows or *nix? And are you doing this over ftp?

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 9:24 am
by Damian2020
I'm on Windows, FTP yes.

chmod?

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 9:26 am
by jackpf
Your server is running windows? Windows default permissions should allow you to write to the file...

In your FTP client, if you right click the file, do you see "chmod" or "permissions" or something?

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 9:38 am
by Damian2020
Ok I see what you mean. I've enabled all of the write permissions and it's now set to 777.

I'm still getting this message:

Notice: Undefined index: company_body in ... file.php on line 9

My PHP code currently looks like this:

<?php
ini_set('display_errors', true);
error_reporting(E_ALL);

//if ($_POST['sendRequest'] == "update_company_page") { // commented out

$company_body = $_REQUEST['company_body'];
$companyFile = "company.txt";
$companyFh = fopen($companyFile, 'w') or die("can't open file");
$companyString = $company_body;
fwrite($companyFh, $companyString);
fclose($companyFh);
?>

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 10:13 am
by Damian2020
I've managed to write the file using a simple string. So it definately works.

It seems the problem lies with getting the $_POST data into the fwrite function.

Is there a way to convert the data to a string maybe? What I've done obviously doesn't work $companyString = $company_body in fact I think it's probably redundant.

Re: Using fwrite with $_POST variables

Posted: Thu Aug 20, 2009 11:10 am
by jackpf
Are you running this from flash now?