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

    Join Date
    Aug 2000
    Location
    Gig Harbor, Washington, USA
    Posts
    29
    Rep Power
    0
    Alex Greg isn't online Okay I need some help.

    I want the user to have some setup options such as changing the name variable, emal varable, among other things in an online format.

    I am not using MySQL with this script.

    So what I was thinking was the following, where $name and $email are the name and email variables, and $enter_name and $enter_email are the user input to change these values in variables.txt:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $fp = fopen($file, "r+");
    $write_to_file = "write the excact same code as in variables.txt except change each value to the users input";

    fwrite($fp, $write_to_file);
    fclose($fp);
    [/code]

    What I mean (the description you see of $write_to_file) is I want it to rewrite variables.txt with the new input.

    So, How can I write PHP code in a variable?

    ------------------
    chris swanicke
    swanicke@defected.net
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    <?
    function changelinline($list,$email,$enter_email)
    {
    $results = file($list);
    while (list(,$path) = each($results))
    {
    $parts = explode(':', $path);
    $path = $parts[0];
    $fp = fopen("$list", 'r');
    if ($fp)
    {
    $data = fread($fp, filesize($list));
    fclose($fp);
    $newdata =eregi_replace($email, $enter_email, $data);
    $fp = fopen($list, 'w');
    if ($fp)
    {
    fwrite($fp, $newdata);
    fclose($fp);
    }

    }
    }
    return(" <br>Occurences of $email replaced with $enter_email");
    }
    ?>

    Try calling this functions twice, once for changing name and once for email or modify a bit to do both at a go. This function accepts filename the old word to replace and the new word to be replaced with and modifies the file.
    Best Of luck then and mail in case it work or any problems regarding it.


    ------------------
    Nikunj
    MYSQL/PHP/XML
    ** Expertise comes with experiece ** Nikunj

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 3
    Last Post: February 11th, 2004, 01:33 PM
  3. functions slowing code
    By dave2k in forum PHP Development
    Replies: 5
    Last Post: February 7th, 2004, 06:40 PM
  4. writing code to another frame
    By khag7 in forum HTML Programming
    Replies: 5
    Last Post: February 6th, 2004, 10:05 PM
  5. Ensuring a file's code doesn't cause error in another.
    By Jason Doucette in forum C Programming
    Replies: 0
    Last Post: February 6th, 2004, 12:51 PM

IMN logo majestic logo threadwatch logo seochat tools logo