SitePoint Sponsor

User Tag List

Results 1 to 16 of 16

Hybrid View

  1. #1
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Script not updating csv file

    I have installed php script on my server and att works fine as far as sending the form contents to my email. I also want it to update to a csv file so that I have a database that can be used elsewhere.

    I am using tectite formmail and they say that in the php file I need to have the following: $CSVDIR = "/home/your-site/csvdir";

    I have tried all the possibilities I can think of as to what I should put here but nothing works. The website is at www.denvor.bartwebsites.com

    I have tried:
    denvor.bartwebsites.com/csv_files/
    /denvor.bartwebsites.com/csv_files/
    /home/denvor.bartwebsites.com/csv_files/
    home/denvor.bartwebsites.com/csv_files/
    /hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/


    I get an error email with the following comment: Failed to open CSV file "/hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/formdata.csv": failed to open stream: Permission denied
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This will tell you the base directory:
    PHP Code:
    <?
    echo $_SERVER['DOCUMENT_ROOT'];
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, but now for the very (to you) stupid question; "What do I do with that code?"

    Do I insert that into the php file, and if so what can I expect from it?
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    no, you just put it in a file of it's own, and run it.

    It'll tell you the path to the document root - the base document folder.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created the file, got the answer, updated my php formmail file, uploaded it and ran the form submission again.

    Got this:

    Failed to open CSV file "/hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/formdata.csv": failed to open stream: Permission denied

    Do you think the problem could be with my host?
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    what happens if you chmod (in the file properties) the CSV file to 777?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is a plain text file and has no permissions tab under Properties.

    The instruction for creating the csv file said to create an empty text file and call it formdata.csv
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    may sound like a stupid question, but the csv file is in the csv_files folder, right?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  9. #9
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Correct.
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  10. #10
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    maybe it is chmod then...
    try running this (a separate file):
    PHP Code:
    chmod("/hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/formdata.csv"777); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  11. #11
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It returned:

    chmod("/hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/formdata.csv", 777);
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  12. #12
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    you have to put them between PHP tags.
    PHP Code:
    <?php
    chmod
    ("/hsphere/local/home/romuba/denvor.bartwebsites.com/csv_files/formdata.csv"0777);
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  13. #13
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that - I don't know php very well at all.

    That done, now there is a blank screen - nothing returns.
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  14. #14
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ok. That's alright - it just sets the full permissions on the file.

    What happens when you run the formmail file?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  15. #15
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Back to the same error message - I think I will contact my hostong company and check with them.
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com

  16. #16
    SitePoint Addict Romuba's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have eventually received a reply. They said that there were two issues that needed attention.
    1. They needed to set the correct permissions on teh folders.
    2. The file I had uploaded was empty adn was incorrect.

    As to 1. I understand that, but as to 2. I read the explanation on the Tectite tutorial and they said that one must make an empty text file and call it formdata.csv and place it on the server. My support guys said that the php script will create the file itself.

    Any thoughts? It is working beaitufully now by the way.
    Ross Bartholomew
    Web Designer/Developer
    BartWebSites
    E-mail: ross@bartwebsites.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •