PHP and MSSQL - executing php code from mssql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laural4705
    New Member
    • Oct 2007
    • 3

    PHP and MSSQL - executing php code from mssql

    Hi, I would like to know if this is possible, I have a sql table that has a paragraph in a varchar field. I can query the database and pull this field in, it renders perfectly, except for the php code that is in the text. Can php be executed from within the results of a sql query, if so, how? (if it is relevant, I am using mssql, php and iis)

    Here is the text (snip) - (how it looks in view source):
    Code:
    Such breakdowns can temporarily leave families scrambling for care at the last minute.</p><p class="body_copy_12on14"> <?php  echo $_SESSION['nameCompany']; ?> offers its employees
    Here is the text (snip) - (how it looks on the web page):
    Code:
    Such breakdowns can temporarily leave families scrambling for care at the last minute. offers its employees
    The php code executes fine if I type it into the page directly, so I know that the session is set (btw, I changed the php code in the paragraph in sql and just tested "hello" and that would not execute either)...

    anyone know how I can make this work? Thanks so much....

    Laura
    Last edited by Atli; Oct 5 '07, 11:37 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi Laura. Welcome to The Scripts!

    The PHP code is not getting executed because it is being handled as a string and sent to the browser.

    Try running it through the eval() function.

    Comment

    • laural4705
      New Member
      • Oct 2007
      • 3

      #3
      Thank you so much, this is just what I was looking for!

      :)

      You made my day!

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Glad I could help :)

        Don't hesitate to post again if you have any more questions or problems we can help with.

        Comment

        Working...