01272006 1137 GMT-6

I had to restart Firefox because of a movie crashed but after doing so, 
I could read - particially - from the file. I didnt think I had to 
restart the browser but that worked.

Yes, I have the ownership set to www-data. The file is in the var/www 
folder.

However, I said partically above because it only reads the first line of 
the file.
I wrote five quotes to the file...

Sorry... the purpose of the tutorial was to write to quotes.txt a quote. 
And then the next tutorial was to read from it. It reads one of the 
quotes randomly.

I wrote five quotes to the file, and looked to make sure they were 
written. And now I can read the first quote only.

This is the code:

        <?php //Script 11.3 - new_quote.php

                // This script displays and handles on HTML form.
                // It takes text input and stores it in a text file to show.

                ini_set('display_errors', 1);
                error_reporting(E_ALL & ~E_NOTICE);

                // Read the files contents into an array.
                $data = file('../quotes.txt');

                // Count the number of items in the array. 
                $n = count ($data);

                // Pick a random item
                $rand = rand (0, ($n - 1));

                // Print the quotation.
                print '<p>'. trim($data[$rand]) . '</p>';

            ?>    

After it reads the first quote, if I hit refresh it loads nothing. I can 
do that four times and then the first quote will show again.

Wade


James Keeline wrote:

>--- Wade Smart <[EMAIL PROTECTED]> wrote:
>
>
>>Im doing a tutorial on reading and writing files.
>>Im on Ubuntu linux.
>>
>>The tutorial said that the file must already exist so that you 
>>can set the permissions on it. So I created a file and set the 
>>user and group to www-data. I set the permissions as 0666. I 
>>can write to the file. I cannot read from it. I have the 
>>ini_set to display errors and error reporting set to E_ALL & 
>>~E_NOTICE. When I attempt to read the file nothing
>>is on the page and in the code there is only <p></p>.
>>
>>Would someone give me a pointer on this.
>>
>>Thanks.
>>
>>Wade
>>
>
>I assume that your Apache web server is running as the user www-data on 
>Ubuntu?  If so, you won't
>need 666 (-rw-rw-rw-) permissions on the file since you have changed the 
>ownership.  You could set
>it to 600 (-rw-------) and it should still work.
>
>However, this does not address your inability to read the file with PHP.  Is 
>the file in the web
>space?  If so, can you read it directly with a browser pointing to a 
>corresponding URL?
>
>If the file is outside of the web space there is a chance that safe_mode is on 
>in php.ini which
>would prevent PHP programs from reading files owned by a different user than 
>the PHP script.
>
>If you use:
>
>error_reporting(E_ALL);
>
>at the top of your program you should see all of the errors, including any 
>safe_mode violations.
>
>James
>_____
>
>
>James D. Keeline
>http://www.Keeline.com  http://www.Keeline.com/articles
>http://Stratemeyer.org  http://www.Keeline.com/TSCollection
>
>http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
>Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.
>Spring Semester Begins in late January.  Two new class topics.
>
>
>Community email addresses:
>  Post message: [email protected]
>  Subscribe:    [EMAIL PROTECTED]
>  Unsubscribe:  [EMAIL PROTECTED]
>  List owner:   [EMAIL PROTECTED]
>
>Shortcut URL to this page:
>  http://groups.yahoo.com/group/php-list 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>


[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to