SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Viewing File

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Viewing File

    I'm having trouble with the below code:

    PHP Code:
    $filename "email.txt";
    $file implode("\n",file($filename));
    echo 
    $file;
    $stuff explode("|^|",$file); 
    $stuff[0] = $Subject;
    $stuff[1] = $FromEmail;
    $stuff[2] = $FromName;
    $stuff[3] = $Msg;
    print 
    $Subject
    It should open a file, read it, make it a single variable, then explode it so I can use seperate parts. But somewhere it is going wrong as it doesn't show the stuff on the page, but it does echo $file, not $Subject;

    Any ideas?

    -Peter

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    None
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd use:

    File name: email.txt
    Contents of email.txt:

    Hey Dude
    some@email.com
    Some User
    Hi There, how are you?

    PHP Code:
    <?
    $email 
    "email.txt";
    $fp fopen($email,"r");
    $email_contents fread($fpfilesize($email));
    $text explode("\n",$email_contents);
    $subject $text[0];
    $from $text[1];
    $name $text[2];
    $message $text[3];
    fclose($fp);
    echo 
    "
    Subject: 
    $subject<br>
    From: 
    $from<br>
    Name: 
    $name<br>
    Message: 
    $message<br><br>
    "
    ;
    ?>

  3. #3
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flip the way you're assigning the variables. Supposedly I seem to recall it makes no difference but it can't hurt to try.

    PHP Code:
    $filename "email.txt";
    $file implode("\n",file($filename));
    echo 
    $file;
    $stuff explode("|^|",$file); 
    $Subject $stuff[0];
    $FromEmail $stuff[1];
    $FromName $stuff[2];
    $Msg $stuff[3];
    print 
    $Subject
    Kevin


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
  •