Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts

    Beginner's php questions please

    I am confused here concerning the opening and editing of files. If you are designing a website using php coding, you name this file's extension .php not so? If yes, according to the tutorials, why use php coding to open and edit a .txt file when you can simply do so using notepad?

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    I don't know why you're asking about using php to open a .txt file. You might do this if you want your script to automatically read / edit a file on the server (EG a log file) but this is different from doing things manually using notepad.

    Also you may be getting confused with how to edit a .php file. This is done in notepad (or similar) where you edit your code and then save it.

    To recap:
    php files are named with a .php extension. To open and/or edit you use a text editor.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts
    ok got it now, I see now how the changes are made to the txt file via the php code, thanks but now the txt file doesn't show any new changes I make to the php code, any reason why?

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    The txt file.. which one? - We seem to still be talking about 2 different txt files.

    When you edit the .php file be sure to save it, when you reopen the changes you made will still be there.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    mikehende (05-24-2011)

  • #5
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts
    I am working with this script which deals with

    PHP - File Upload: move_uploaded_file Function

    but need some help in breaking this down where the "names" are concerned which are bolded below:
    Code:
    $target_path = "uploads/";
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    Can you advise me on those 3 names issues above please? In other words, those 3 names need to be replaced with what exactly?

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Names from your form fields...

    Please don't confuse the topic. I've asked you a question about your text files and you've returned with a completely new question which seems to be unrelated.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #7
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    not exacly sure what your asking here, but if your wanting to use that script with your program, just replace "uploadedfile" with the name of your upload field.


  •  

    Posting Permissions

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