Hello Monks,

I have a series of dynamic web pages that have (a lot) of common code. I've decided that one way to make sure any updates to said code are propagated across the entire site is to store some of the code inside the database itself.

One of the things that is stored is the HTML header for every page, which, aside from the page name, is the same. The page name itself doesn't change, but is based on another variable stored somewhere else.

I've got the whole header stored in the database, in a LONGTEXT (I believe) type field (I'll verify and post if it's different - I'm not in front of the thing at the moment). There is ALSO a perl variable stored in the header (in the database) - $config{'pagename'} - and when this information gets pulled from the db and printed, it somehow does not get interpreted by perl, and prints EXACTLY as the variable name (without being replaced - e.g. $config{'pagename'}).

I inserted the header information into the appropriate field in the database using phpmyadmin - I copied it directly from working code in my script.

Can anyone direct me as to why it is that I'm getting "escaped" variables in the output? Do I need to escape the variable name BEFORE it goes into the database, so that perl can interpret it properly when it gets read and printed?

ps I'm using the Mysql perl module... perhaps obviously.

pps here's a sample (but not exactly), just to give you the idea of what I'm talking about. The following would be stored in the database field:

<HTML> <HEAD> <title>$config{'pagename'}</title> ... some other header information, such as javascripts ... </HEAD> <BODY>

And when it prints out, the $config{'pagename'} is printed exactly as that without interpretation...

Thanks in advance!

-r-


In reply to Perl variable names stored in mysql fields by RyanJ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.