This topic is locked

Insert Javascript into the database

10/8/2008 9:28:45 AM
PHPRunner General questions
J
jetacera author

I have a client who wants to periodically swap out javascript code on various pages of his website (i.e. to pull up ads from various affiliates such as Google AdSense and others). We would like to do this using a database, but do not know if this is possible. We have always added javascript code to the php/html file itself (using the {literal} tags for phpr templates when necessary) rather than into the database.
In my experience, inserting any javascript code into the My SQL database using phpr has caused whatever database record the script is in to cease functioning - i.e. it will no longer pull up when called for. If the javascript is removed (via phpmyadmin), the record works fine again.
Is there a way to add javascript code into a database record to prevent this from happening? I have tried searching the internet for an answer, but have not found one.
Thank you for any assistance.
Janet

U
unimatrix 10/9/2008

store the javascript as text in a text field then print that field where ever needed. We do this with CSS on one of our sites. All the CSS information is stored in the database and then on the PHP pages we had a <?php print $info->CSS; ?> in the <head> of the page and it works fine.
Granted that is a custom coded application, we just created at the admin menu with phprunner.