evaluating variable in different statement

Discussion in 'PHP' started by harte, Jan 30, 2010.

  1. #1
    Sorry I love to figure out things for myself but need some beginner direction.
    I'm trying to use _GET to pass a variable to php and modify a Java applet configuration file.
    <?php
    $symbol = $_GET['symbol'];
    $text1 = @file_get_contents("ondemand.txt") or die("file not found!");
    print "$symbol";
    print "$text1";

    The portion of ondemand.txt I'm trying to modify
    <param name="symbol" value = "$symbol">

    it evaluates the variable in print "$symbol"; but not in
    <param name="symbol" value = "$symbol">

    Help Please :)
     
    harte, Jan 30, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    If i understand you correctly, this should be what you need:

    <?php
    error_reporting(E_ALL);
    $symbol = $_GET['symbol'];
    
    $text1 = file_get_contents("ondemand.txt") or die("file not found!");
    
    $text1 = preg_replace("@<param name=\"symbol\" value = \"(.*)\">@", "<param name=\"symbol\" value = \"$symbol\">", $text1);
    
    echo $text1;
    
    ?>
    PHP:
     
    danx10, Jan 30, 2010 IP
  3. harte

    harte Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow thanks you're good

    I'll study what you did thanks again.
     
    harte, Jan 30, 2010 IP