Results 1 to 3 of 3

Thread: [RESOLVED] Problem when using php code in messages

  1. #1
    Join Date
    Jun 2014

    resolved [RESOLVED] Problem when using php code in messages


    I am having a problem here... I want to insert php code in a message (for one of the messages in the message block of the screen).

    The message body is stored in a database as text. When the page is displayed, the inserted php code is treated as text too and is not runned properly... I tried different things and nothing seem to work.

    Is anyone have any idea of how to do that?

    This is the php code line I want to insert in my message: .strtoupper(_CURRENT_MONTH_)."SPECIALS"

    Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    You would probably have to make use of eval(), but, "If eval() is the answer, you're probably asking the wrong question." More secure would be to just embed some sort of place-holder in there, then replace it via str_replace() or sprintf(), or printf(). E.g.:
    PHP Code:
    $textFromDB "blah blah blah _CURRENT_MONTH_ blah blah blah";
    str_replace('_CURRENT_MONTH_'date('F'), $textFromDB); 
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Jun 2014
    Thank you NogDog!

    It worked perfectly!

    I should have seen that solution... Too easy!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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