[PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 12:20 AM, Ethan Rosenberg wrote:

Dear list -

When I use  fopen, the  file owner and group are both www-data.

How can I ensure that the owner and group will be ethan?

TIA

Ethan


Why should ownership be a concern when you are simply opening a file? 
AFAIK permissions are set at the time the file is placed there and will 
affect the access to them from then on.  If you are able to fopen the 
file, why do the permissions matter?  If you can't then you have an 
entirely different problem to discuss.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: www-data file

2014-08-26 Thread Matt Pelmear

On 08/26/2014 06:21 AM, Jim Giner wrote:

On 8/26/2014 12:20 AM, Ethan Rosenberg wrote:

Dear list -

When I use  fopen, the  file owner and group are both www-data.

How can I ensure that the owner and group will be ethan?

TIA

Ethan


Why should ownership be a concern when you are simply opening a file? 
AFAIK permissions are set at the time the file is placed there and 
will affect the access to them from then on.  If you are able to fopen 
the file, why do the permissions matter?  If you can't then you have 
an entirely different problem to discuss.




fopen() can create files if they don't exist.
So if you open a file for writing, it will by default receive the 
user/group of the web server. If you then need to access the file as 
some other user, you run into this situation.

(I assume this is what Ethan is referring to here.)

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] www-data file

2014-08-26 Thread Jasper Kips
What are you trying to achieve? Or to put it more clearly, why do you need the 
filw owner to be ethan?

Jasper

Verstuurd vanaf mijn iPad

 Op 26 aug. 2014 om 06:20 heeft Ethan Rosenberg 
 erosenb...@hygeiabiomedical.com het volgende geschreven:
 
 Dear list -
 
 When I use  fopen, the  file owner and group are both www-data.
 
 How can I ensure that the owner and group will be ethan?
 
 TIA
 
 Ethan
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 11:26 AM, Matt Pelmear wrote:


fopen() can create files if they don't exist.

I should have read the manual b4 replying.  :(

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Writing Problems

2014-08-26 Thread Ethan Rosenberg

Dear List -

I can't figure this one out.

1] Straighten out ownership

ethan@meow:/var/www$ rm receipt.txt
ethan@meow:/var/www$ touch receipt.txt
ethan@meow:/var/www$ ls -l receipt.txt
-rw-r--r-- 1 ethan ethan 0 Aug 26 19:31 receipt.txt
ethan@meow:/var/www$ chmod 766 receipt.txt
ethan@meow:/var/www$ ls -l receipt.txt
-rwxrw-rw- 1 ethan ethan 0 Aug 26 19:31 receipt.txt

This is what we want

2] Now program code 

ini_set('display_startup_errors', 'on');
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors','1');
error_reporting(1);


$fh2 = fopen(/var/www/receipt.txt, a+);

want this file to be like a cash register receipt.  I can truncate this 
file for each execution of the program; ie, when all the purchases are 
finished.


$sql3 = select quant, orderpt,  ordrpt_flag, manuf, item, stock, price, 
tax_flag  from Inventory where UPC = $upc;

$result3 = mysqli_query($cxn, $sql3);
$row3 = mysqli_fetch_row($result3);

print_r($row3 ); //gives correct results.

$numbyt=fprintf($fh2, %s %s %.2f %s\n,$row3[3] , $row3[4], $row3[6], 
$row3[7]);


echo br /numbyt fh2 $numbytbr /;//result is 0

No errors.

What is wrong??

TIA

Ethan

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Writing Problems

2014-08-26 Thread Matt Pelmear
Do you check whether $fh2 is a resource after you fopen()?

btw, a better way than:
$ chown ethan:ethan filename.txt
Might be:
$ chown ethan:www-data filename.txt
$ chmod 664 filename.txt

This way you own the file, the server can write to it (assuming your server
has group www-data), and it is not world-writeable. (you almost never want
things to be world-writeable)

Matt
On Aug 26, 2014 5:45 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com
wrote:

 Dear List -

 I can't figure this one out.

 1] Straighten out ownership

 ethan@meow:/var/www$ rm receipt.txt
 ethan@meow:/var/www$ touch receipt.txt
 ethan@meow:/var/www$ ls -l receipt.txt
 -rw-r--r-- 1 ethan ethan 0 Aug 26 19:31 receipt.txt
 ethan@meow:/var/www$ chmod 766 receipt.txt
 ethan@meow:/var/www$ ls -l receipt.txt
 -rwxrw-rw- 1 ethan ethan 0 Aug 26 19:31 receipt.txt

 This is what we want

 2] Now program code 

 ini_set('display_startup_errors', 'on');
 error_reporting(E_ALL | E_NOTICE);
 ini_set('display_errors','1');
 error_reporting(1);


 $fh2 = fopen(/var/www/receipt.txt, a+);

 want this file to be like a cash register receipt.  I can truncate this
 file for each execution of the program; ie, when all the purchases are
 finished.

 $sql3 = select quant, orderpt,  ordrpt_flag, manuf, item, stock, price,
 tax_flag  from Inventory where UPC = $upc;
 $result3 = mysqli_query($cxn, $sql3);
 $row3 = mysqli_fetch_row($result3);

 print_r($row3 ); //gives correct results.

 $numbyt=fprintf($fh2, %s %s %.2f %s\n,$row3[3] , $row3[4], $row3[6],
 $row3[7]);

 echo br /numbyt fh2 $numbytbr /;  //result is 0

 No errors.

 What is wrong??

 TIA

 Ethan

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php