English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to insist to php, to break after it has writen an ip address and date, but it will actually write "
," and "/n" how can i actually make it break with a new line.
=========================...
function ipset(){
$ip = $_SERVER["REMOTE_ADDR"];
$new_file = "addresses.txt";
$file_handle = fopen($new_file,'a');
fwrite($file_handle,
$ip."-".date("m/d/Y").
"
")/n;
fclose($file_handle);
ipset();
}
?>
=========================...

OUTPUT in textfile:
(making more than one line because text box won't let me put long strings...)
=========================...
69.152.147.191-06/06/2007
(continue string on next line*)

69.152.147.191-06/06/...
(continue string on next line*)


=========================...

2007-06-06 07:25:24 · 3 answers · asked by truepal20032001 2 in Computers & Internet Programming & Design

3 answers

I can't test these suggestions for you, but give them a try.

1) Try sending this to your file before you write anything you want rendered as HTML: echo "Content-type: text/html\n\n";
2) Try changing the extension on your file from txt to html
3) Surround your text with data here

Also, you may want to have a php file with all the header information etc and between the body tags include a "require_once()" referencing the above file. If you have properly structured php file that outputs legitimate html, you should be able to include (require) a text file like what you suggest above and get the results you were expecting.

The Data Analyst - http://www.squidoo.com/thedataanalyst

2007-06-06 07:40:42 · answer #1 · answered by a_non_a_miss_2000 3 · 1 0

1. It actually writes
because you include that in your fwrite command. If you don't want it, then don't put it there in the code.

2. It does not write newlines, because the escape code for newline is \n (not /n).

2007-06-06 15:07:25 · answer #2 · answered by Joris 2 · 0 0

Change: fwrite($file_handle,
$ip."-".date("m/d/Y").
"
")/n;


To:

fwrite($file_handle, $ip . "-" . date("m/d/Y") . "\n");

2007-06-06 15:06:07 · answer #3 · answered by Dave W 1 · 0 0

fedest.com, questions and answers