SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    eCommerce specialist hotnuts21's Avatar
    Join Date
    Apr 2002
    Location
    Aberystwyth, UK
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why does this not replace?

    This bit of code, reads a txt file and then outputs the contents of that file into part of the page. I added the string replace line to replace the email address that appears in the text file, mainly because I dont want the email to show up on each page for obvious reasons. However its not replacing the email address, any suggestions?

    PHP Code:
    function displayLargeDescription($dir)
        {
        

            
    $handle fopen($dir $this->large_description_file"r");
            while (!
    feof($handle)) {
                
    $buffer fgets($handle4096);
                
    str_replace("email@email.co.uk"," ",$buffer);
                if (
    $buffer == strtoupper($buffer))
                    echo 
    '<strong>' $buffer "</strong><br />";
                else
                    echo 
    $buffer '<br />';
            }
            
    fclose($handle);    } 
    Search & Rescue Aberystwyth Lifeboat
    CSS Tutorials/Guides

    Sitepoint signatures are not visible to Search Engines More info

  2. #2
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    str_replace("email@email.co.uk"," ",$buffer); 
    Do you just not just need to replace the above with

    PHP Code:
    $buffer=str_replace("email@email.co.uk"," ",$buffer); 
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  3. #3
    eCommerce specialist hotnuts21's Avatar
    Join Date
    Apr 2002
    Location
    Aberystwyth, UK
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course, silly me I didnt even think of that.

    Many thanks for pointing that out.

    Is this the best way to do this they are large files, is the server load high for checking through the entire folder? I suppose there is not much choice though?
    Search & Rescue Aberystwyth Lifeboat
    CSS Tutorials/Guides

    Sitepoint signatures are not visible to Search Engines More info

  4. #4
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is using a database not an option you could consider
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  5. #5
    eCommerce specialist hotnuts21's Avatar
    Join Date
    Apr 2002
    Location
    Aberystwyth, UK
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The site is using a database and most of the information is stored in a sql database.
    However a part of each page changes daily and this information is uploaded to the server daily, in the form of a text file. So the text file is read and displayed. Then deleted when a new one is uploaded.
    Search & Rescue Aberystwyth Lifeboat
    CSS Tutorials/Guides

    Sitepoint signatures are not visible to Search Engines More info

  6. #6
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats a shame, why not create a small table in the database and a php page where whoever could just copy and paste the data and then save to the database
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  7. #7
    SitePoint Member steamboy's Avatar
    Join Date
    May 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with trekmp. Its much easier.

  8. #8
    eCommerce specialist hotnuts21's Avatar
    Join Date
    Apr 2002
    Location
    Aberystwyth, UK
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the thoughts. I will look into what is an easier option.
    Search & Rescue Aberystwyth Lifeboat
    CSS Tutorials/Guides

    Sitepoint signatures are not visible to Search Engines More info


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
  •