Variable from MySQL DB

Discussion in 'PHP' started by JohnUK, May 15, 2009.

  1. #1
    Hi Guys,

    I want to import some code from my SQL db which has php variables in. But when I import and try to use the variables they remain the code and dont take up the values

    e.g.
    DB:
    table [0] = vara
    table [1] = varb

    -----
    $varb = 4;
    $out = mysql select table [1]
    echo $out would output $varb instead of 4 :(

    Ive tried something similar with importing from files but no luck so far. Any ideas on how to do this???

    Thanks.
     
    JohnUK, May 15, 2009 IP
  2. aaron d.

    aaron d. Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use $$table[1].
     
    aaron d., May 16, 2009 IP
  3. JohnUK

    JohnUK Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the suggestion. Ive just tested it but the problem persists:

    Great news you have a new Lesson Booking!. The Lesson is booked for $$booking[4] on $$booking[2]/$$booking[3]/2009. Please confirm availability to continue processing the lesson.

    see the $$booking[4] should have changed to a value like 100 but it remains like txt. Any other ideas?
     
    JohnUK, May 18, 2009 IP
  4. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #4
    Use eval in this case, ht*p://ww.php.net/eval.
    Example;
    <?php
    	$test[0] = "ASDF";
    	$y = "\$test[0]";
    	eval("\$y = \"$y\";");
    	echo $y;
    ?>
    PHP:
     
    Sky AK47, May 18, 2009 IP
    mussolinihitler likes this.
  5. JohnUK

    JohnUK Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Quality. That done the trick. Thanks man.
     
    JohnUK, May 18, 2009 IP
  6. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #6
    Ok, no problem at all. Good luck with any further coding and feel free to PM for help.
     
    Sky AK47, May 18, 2009 IP