Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

How can I reproduce this code in a MySql database?

I have a page that you can see at

It's a google map that you can view at The thing I'm trying to do is store the map code in a mysql database and reproduce the code using the following select statement:

$george = "select * from state_maps where state_name='$_GET[state_name]'";
            echo $george;
            $george_query = mysqli_query($cxn, $george)
            or die("Couldn't execute query.");
            $george_count = mysqli_num_rows($george_query);
            $george_row = mysqli_fetch_assoc($george_query);
            $video_script = html_entity_decode($state_map);
            echo $video_script;      

I'm inputting the code using $map_code = htmlspecialchars("$_POST[map_code]", ENT_QUOTES); While it's worked in the past with HTML, I'm wondering if this is going to happen with Javascript.

Bottom line question: Can I store the Javascript in a Mysql database and reproduce it the way that I'm trying to do, or am I attempting the impossible?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Javascript loaded After the page is loaded does not get recognized without some special effort.  If it is loaded with the rest of the page content, it can work.
Avatar of Bruce Gust


Thanks for the feedback, Dave. How would I load it, or can I, with the rest of the page?
The same way you load anything from a database...
Alright, but here's the problem:

When I insert this code into the database, I'm using $map_code = htmlspecialchars("$_POST[map_code]", ENT_QUOTES); and then when I publish it on to my page, I'm using       $video_script = html_entity_decode($state_map);
      echo $video_script; when you look at source code of the database driven page that's now working correctly, you'll see var contentString = &#039;<div id="content">&#039;+  instead of var contentString = '<div id="content">'+

Is that a dealbreaker and if so, how do I get around it?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Dave! I'll implement your counsel and see what I can come up with. One other thing that recently surfaced as a challenge that needs to be addressed: I was able to get the page working by breaking things down until something, "broke" and was able to uncover a conflict between the google map stuff and another piece of code that produces a scrolling text. I've got the question out at and would love for you to take a look at it if you've got a minute.