Title: Problems embedding Javascript within PHP
Last modified: August 19, 2016

---

# Problems embedding Javascript within PHP

 *  Resolved [hoov](https://wordpress.org/support/users/hoov/)
 * (@hoov)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problems-embedding-javascript-within-php/)
 * Hi guys, I’ve installed the Exec-PHP and Inline Javascript plug-ins for a project
   I’m working on. Up to this point the PHP has been separate from the Javascript,
   but I need to populate a JS array from a MySQL query.
 * What I’d like to know is if it’s at all possible to embed Javascript within PHP(
   or vice versa) using these plug-ins. So far what I’ve tried hasn’t been working.
 * I found this site: [http://codingforums.com/showthread.php?t=52060](http://codingforums.com/showthread.php?t=52060)
 * But unfortunately I can’t seem to embed the two languages together. The following
   code appears to do nothing:
 *     ```
       [inline]
       <script type="text/javascript">
       <?php echo 'asdfsadfa';?>
       </script>
       [/inline]
       ```
   
 * And this will throw a syntax error because of the [inline] tags:
 *     ```
       <?php
       [inline]
       <script type="text/javascript">
       document.write('Hello World!');
       </script>
       [/inline]
       ?>
       ```
   
 * Is there any way to accomplish what I’m doing? I don’t know Javascript too well.
   The array is supposed to collect latitude/longitude points so I can put them 
   down as markers on a Google map.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problems-embedding-javascript-within-php/#post-1276547)
 * Try using php to echo all the javascript:
 *     ```
       <?php
       echo "<script type='text/javascript'>\n";
       echo "document.write('Hello World!');\n";
       echo "</script>";
       ?>
       ```
   
 *  Thread Starter [hoov](https://wordpress.org/support/users/hoov/)
 * (@hoov)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problems-embedding-javascript-within-php/#post-1276563)
 * Thanks! Didn’t even think to try that.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problems embedding Javascript within PHP’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [hoov](https://wordpress.org/support/users/hoov/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/problems-embedding-javascript-within-php/#post-1276563)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
