#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Omaha
    Posts
    5
    Rep Power
    0
    Hello,

    I recieved some help from someone on this forum last night for how to save the contents of a file to a variable and then include that variable into a mail function.

    Unfortunately, everything on the script BUT the file thing works. Here's the code that supposedly includes the file into the variable:

    <?
    if ($tlevel=="1") {
    $fp = fopen("j1test.txt", "r");
    $test = fread($fp, filesize("j1test.txt"));
    fclose($fp);
    }
    if ($tlevel=="2") {
    $fp = fopen("j2test.txt", "r");
    $test = fread($fp, filesize("j2test.txt"));
    fclose($fp);
    }
    if ($tlevel=="3") {
    $fp = fopen("j3test.txt", "r");
    $test = fread($fp, filesize("j3test.txt"));
    fclose($fp);
    }
    mail("$email","Judge Test",$test);
    echo("It worked! W00t!");
    ?>

    When it sends the mail, all it sends is a blank message, any ideas? Thanks in advance!

    Michael

  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    28
    Rep Power
    0
    Are you sure that $tlevel is 1, 2, or 3? Because if it's not, $test won't be defined. I suggest you try setting a default value to $test at the beginning to test this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Netherlands
    Posts
    32
    Rep Power
    15
    Hello Michael,

    I know what you mean.
    Here is it how I do it:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    function get_path2() {
    $rUri = getenv("SERVER_NAME");
    if ($rUri == "localhost") $WWW_PATH = "http://" . $rUri . "/localsubdir/";
    else $WWW_PATH = "/your/domain.com/html/";
    return $WWW_PATH;
    }

    $filename = get_path2() . "bla/subbla/bla.txt";
    $fd = fopen($filename, "r");
    $body = fread($fd, filesize($filename));
    fclose( $fd );

    mail("$email","Hello Michael","$body","From: Michael@domain.comnReply-To: Michael@domain.comnX-Mailer: PHP/" . phpversion());
    [/code]

    This works fine.


    Can anybody help me with:
    http://www.devshed.com/Talk/Forums/F...ML/003273.html

Similar Threads

  1. Replies: 4
    Last Post: May 18th, 2004, 05:21 AM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  3. Replies: 1
    Last Post: February 8th, 2004, 01:59 PM
  4. Upload file name problem
    By clio in forum PHP Development
    Replies: 1
    Last Post: February 6th, 2004, 06:19 AM
  5. Problem with opening a file
    By Psantiago in forum C Programming
    Replies: 3
    Last Post: February 3rd, 2004, 07:31 PM

IMN logo majestic logo threadwatch logo seochat tools logo