Announcement

Announcement Module
Collapse
No announcement yet.

making php realize the php code

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • making php realize the php code

    I'm keeping this "template" in a mysql database, and one template looks like this:

    Your username is $username and your password is $password

    and in the beggining of the whole php file, I specify the $username and $password, how would I get it to print out the variables


    I believe I need to use something like eval

    thanks,

    Dimava
    NXSupport Admin

  • #2
    From the PHP docs:
    Example 1. eval() example - simple text merge

    Code:
    <?php
    $string = 'cup';
    $name = 'coffee';
    $str = 'This is a $string with my $name in it.<br>';
    echo $str;
    eval ("\$str = \"$str\";");
    echo $str;
    ?>

    The above example will show: This is a $string with my $name in it.
    This is a cup with my coffee in it.
    --filburt1, vBulletin.org/vBulletinTemplates.com moderator
    Web Design Forums.net: vB Board of the Month
    vBulletin Mail System (vBMS): webmail for your forum users

    Comment


    • #3
      oh ok, thanks
      NXSupport Admin

      Comment


      • #4
        PHP Code:

                
        while ( list ( $staffid$username ) = mysql_fetch_row $result ) ) {
                    
        $templateContent funGetTemplate("admin_staff_list_item");
                    eval (
        "\$templateContent = \"$templateContent\";");
                    Echo 
        $templateContent;
                } 

        Parse error: parse error in /home/staff.php(34) : eval()'d code on line 2

        and line 34 would be the line with eval in it


        thanks,

        Dimava
        NXSupport Admin

        Comment


        • #5
          I figured it out, i had to addslashes to the string before i eval'ed it
          NXSupport Admin

          Comment

          Working...
          X