Jump to content

How to print a white space to a text file?


paymentstv

Recommended Posts

Hello, I have the following code writting IP,session, and date to a text file (it works) but I want to add a white space after the IP address.

fwrite($fp, $_SERVER['REMOTE_ADDR'].  $_SESSION["sess_name"].  " $dateTime\r\n");

 

At the moment it prints like this

16.17.51.41SESSION_ID 2011/01/23 12:53:32

 

thanks in advance.

Link to comment
Share on other sites

ok my bad,

 

this actually worked.

fwrite($fp, "{$_SERVER['REMOTE_ADDR']}{$_SESSION["sess_name"]} {$dateTime}\r\n");

 

just had to add a space between {$_SERVER['REMOTE_ADDR']} and {$_SESSION["sess_name"]}

Also i currently have

 

$fp = fopen('ip.txt', 'a');

where ip.txt is hosted in the same folder of server

What if i want to write to a file hosted in a different server ? http://domain.com/folder/ip.txt..etc

would

$fp = fopen('http://domain.com/folder/ip.txt', 'a');

work? tried but not writing with chmod 777

 

 

1. What would be the file permission of ip.txt?

2. Should I give same permission to the folder where ip.txt is?

 

Link to comment
Share on other sites

Also i currently have

 

$fp = fopen('ip.txt', 'a');

where ip.txt is hosted in the same folder of server

What if i want to write to a file hosted in a different server ? http://domain.com/folder/ip.txt..etc

would

$fp = fopen('http://domain.com/folder/ip.txt', 'a');

work?

 

Think about the security risks of what you are asking if it were that simple to allow someone to edit files on a remote server. A couple of options are you could create a process on the external server to accept requests to update that file or you could programatically download the file via FTP, modify it, then re-upload it via FTP again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.