Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts

    php tags from a database.

    Hello!

    I currently have <?php ?> tags in my database but when i look at the page that calls that record nothing shows up, it just shows the tags in the page source.

    Does anyone know how to fix this?

    James

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: php tags from a database.

    Originally posted by Tidus
    I currently have <?php ?> tags in my database but when i look at the page that calls that record nothing shows up, it just shows the tags in the page source.
    Broken as designed?

    In other words, is there a specific reason you store PHP source code in the database? Why don't use a simple include_once or require_once to import PHP source code into a script? Perhaps a little bit of source code helps clearing up your issue...

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,072
    Thanks
    11
    Thanked 96 Times in 94 Posts
    .. you can eval($from_db) as well though in that case you dont need the <? ?> tags as eval() appears to add them for you, but I am with Mordred in that it seems a strange way to go about things !
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Registered User
    Join Date
    Feb 2003
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey

    If you are retrieving from a DB, then how are you going to make PHP process the script?



    Jesh

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by Jesh
    Hey

    If you are retrieving from a DB, then how are you going to make PHP process the script?



    Jesh
    Using eval() just like firepages said.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #6
    Registered User
    Join Date
    Feb 2003
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey

    firepages says eval() adds the tags and doesn't mention script execution. But sorry, I didn't know it also executes the script, I have never called script from a DB.

    Jesh

  • #7
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok so the row is called news.

    so how exactly would i use the eval() function. I am only a newbie so yeh..

    I have tried a few things but cant figure it out.

    James

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #9
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    sorry. i am there and cant figure it out?

  • #10
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,072
    Thanks
    11
    Thanked 96 Times in 94 Posts
    eg

    PHP Code:
    <?
    $yaks
    =mysql_query("SELECT code FROM tester");
    $str=mysql_result($yaks,0);
    eval(
    $str);
    ?>

    where code in tester is..

    Code:
    for($x=0;$x<=10;$x++){echo "allo from MySQL \n<br />";}
    note that eval() can be a real pain at times.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #11
    New Coder
    Join Date
    Aug 2002
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks everyone!

    Its all working now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •