php-windows Digest 9 Nov 2005 08:56:48 -0000 Issue 2818
Topics (messages 26472 through 26474):
Re: fwrite()
26472 by: Kevin Smith
26473 by: JC Botha
26474 by: Rosty Kerei
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Submit you're code to the list and let's see if we can help you.
JC Botha wrote:
Dear Rosty
Thanks for your input, but it does not change the situation at all! :(
Please let me know if there is something else that you think about.
Greetings
JC
-----Original Message-----
From: Rosty Kerei [mailto:[EMAIL PROTECTED]]
Sent: 08 November 2005 01:32 PM
To: [email protected]
Subject: [PHP-WIN] Re: fwrite()
Maybe you need to replace "\n" to "\r\n"? Like -
$_POST['textbox'] = str_replace("\n", "\r\n", $_POST['textbox']);
Sincerely,
Rosty Kerei
[EMAIL PROTECTED]
""JC Botha"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
Dear Users, thanks for those that helped me last time! I got it working.
At the moment I'm stuck with the fwrite() function. If I use the $_POST to
get the data out of a textbox into a var, and write it to a txt file I get
the following problem. The very first encounter it makes with a "\n" it
stops the string. Thus I do not get more than one paragraph into my txt
file. What should I do to bypass this?
Thanks
|
smime.p7s
Description: S/MIME Cryptographic Signature
--- End Message ---
--- Begin Message ---
I greatly appreciate your help! Thank you so much.
if ($_POST[update] == "update") {
//write info to file
$file_data = "editdate#".date('l d_m_Y')."\n";
$file_data .= "createdate#$_POST[createdate]\n";
$file_data .= "title#$_POST[title]\n";
$file_data .= "description#$_POST[description]\n";
$file_data .= "sender#$_POST[sender]\n";
$file_data .= "letter#$_POST[letter]\n";
$file_data .= "response#$_POST[response]\n";
addslashes($file_data);
$file_data = str_replace("\n", "\r\n", $file_data);
$id = $_GET['id'];
$file_location = "letters/$id";
if (is_writable($file_location))
{
if (!$handle = fopen($file_location, 'w'))
{
echo "Cannot open file ($file_location)";
exit;
}
$_POST['textbox'] = str_replace("\n", "\r\n", $_POST['textbox']);
if (fwrite($handle, $file_data) === FALSE)
{
echo "Cannot write to file ($file_location)";
exit;
}
fclose($handle);
} else {
echo "The file $file_location is not writable";
}
}
------------------------------
*From:* Kevin Smith [mailto:[EMAIL PROTECTED]
*Sent:* 08 November 2005 11:24 PM
*To:* [EMAIL PROTECTED]
*Cc:* 'Rosty Kerei'; [email protected]
*Subject:* Re: [PHP-WIN] Re: fwrite()
Submit you're code to the list and let's see if we can help you.
JC Botha wrote:
Dear Rosty
Thanks for your input, but it does not change the situation at all! :(
Please let me know if there is something else that you think about.
Greetings
JC
-----Original Message-----
From: Rosty Kerei [mailto:[EMAIL PROTECTED] <[EMAIL PROTECTED]>]
Sent: 08 November 2005 01:32 PM
To: [email protected]
Subject: [PHP-WIN] Re: fwrite()
Maybe you need to replace "\n" to "\r\n"? Like -
$_POST['textbox'] = str_replace("\n", "\r\n", $_POST['textbox']);
Sincerely,
Rosty Kerei
[EMAIL PROTECTED]
""JC Botha"" <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Dear Users, thanks for those that helped me last time! I got it working.
At the moment I'm stuck with the fwrite() function. If I use the $_POST to
get the data out of a textbox into a var, and write it to a txt file I get
the following problem. The very first encounter it makes with a "\n" it
stops the string. Thus I do not get more than one paragraph into my txt
file. What should I do to bypass this?
Thanks
--- End Message ---
--- Begin Message ---
Gosh! JC, I used $_POST['textbox'] as an example for you. If you wish to end
your lines by "\r\n" instead of "\n" just do it, like here
$file_data = "editdate#".date('l d_m_Y')."\r\n";
And if you have some textareas on your HTML form, you can change them like
$_POST['textbox'] = str_replace("\n", "\r\n", $_POST['textbox']);
Where 'textbox' is a name of your textarea field. Got it?
Sincerely,
Rosty Kerei <[EMAIL PROTECTED]>
"JC Botha" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I greatly appreciate your help! Thank you so much.
if ($_POST[update] == "update") {
//write info to file
$file_data = "editdate#".date('l d_m_Y')."\n";
$file_data .= "createdate#$_POST[createdate]\n";
$file_data .= "title#$_POST[title]\n";
$file_data .= "description#$_POST[description]\n";
$file_data .= "sender#$_POST[sender]\n";
$file_data .= "letter#$_POST[letter]\n";
$file_data .= "response#$_POST[response]\n";
addslashes($file_data);
$file_data = str_replace("\n", "\r\n", $file_data);
$id = $_GET['id'];
$file_location = "letters/$id";
if (is_writable($file_location))
{
if (!$handle = fopen($file_location, 'w'))
{
echo "Cannot open file ($file_location)";
exit;
}
$_POST['textbox'] = str_replace("\n", "\r\n", $_POST['textbox']);
if (fwrite($handle, $file_data) === FALSE)
{
echo "Cannot write to file ($file_location)";
exit;
}
fclose($handle);
} else {
echo "The file $file_location is not writable";
}
}
--- End Message ---