1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

fwrite php into new page

Discussion in 'PHP' started by weddingm, May 6, 2005.

  1. #1
    Hello,

    I am trying to fwrite a new page with php code in it. The content variable is called $verbage. However, on the new page the $table comes through as blank. How can I code this so it shows the code on the new page??


    $verbage="
    <?php
    require(\"connectdb.inc.php\");
    $table=\"webpagetable\";
    ?>"

    Regards,
    Matt
     
    weddingm, May 6, 2005 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I found that this works
    <?PHP
    $verbage="
    <?php
    require(\"connectdb.inc.php\");
    \$table=\"webpagetable\";
    ?>";
    echo $verbage;
    ?>
    Code (markup):
    The difference is I escape the $ so that it doesn't try to show the value of $table and just takes $table as a string.

    Sarah
     
    sarahk, May 7, 2005 IP
  3. weddingm

    weddingm Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have another question. I have an html form posting to a php page. The value is pulled using the post method. How do I put a posted value into the content that's posted into the new page?

    ......$webinfo7=$_POST['Email'];.......

    $content="
    <?php
    require(\"connectdb.inc.php\");
    \$table=\"webpagetable\";

    \$sql = \"SELECT * FROM webpagetable
    WHERE Email = $webinfo7 \";
    \$result = mysql_query(\$sql,\$connection) or die(\"Couldn't execute query.\");......

    I cannot figure out how to bring the $webinfo7 variable into the new php page. Any help?

    Thanks,
    Matt
     
    weddingm, May 7, 2005 IP
  4. markkk

    markkk Well-Known Member

    Messages:
    1,143
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    140
    #4
    So you want to bring the $webinfo7 to another page.. Honestly Im not great in PHP, but how about creating a session.....


    session_start(); // initialize session

    $_SESSION['webinfo7'] = $webinfo7; // pass the value of webinfo7 to sessionname: webinfo7


    <-------- on the newpage.php ----->

    echo $_SESSION['webinfo7']; //




    I guess this will works..

    Cheers!
     
    markkk, May 13, 2005 IP