Title: Parse error: syntax error, unexpected T_VARIABLE in
Last modified: August 21, 2016

---

# Parse error: syntax error, unexpected T_VARIABLE in

 *  Resolved [grimerking](https://wordpress.org/support/users/grimerking/)
 * (@grimerking)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/)
 * I’m trying to insert the following code into a post:
 *     ```
       <?php
       $my_id = 1149
       $post_id_1149 = get_post($my_id);
       $content = $post_id_1149->post_content;
       $content = apply_filters('the_content', $content);
       $content = str_replace(']]>', ']]>', $content);
       echo $content;
       ?>
       ```
   
 * So, I entered the following into the ‘text’ field:
 *     ```
       [insert_php]
       $my_id = 1149
       $post_id_1149 = get_post($my_id);
       $content = $post_id_1149->post_content;
       $content = apply_filters('the_content', $content);
       $content = str_replace(']]>', ']]>', $content);
       echo $content;
       [/insert_php]
       ```
   
 * The code is supposed to populate the ‘body text’ of the page with the contents
   of post_id_1149. The code is ‘good’ – i.e. if added to page.php it does what 
   it is supposed to do. However, I’m trying to auto-populate the mobile version
   of the site using the content of the desktop version. That way, I only have to
   update the desktop version and the mobile version should automatically reflect
   any updates.
 * Unfortunately, I’m getting the following error:
 * `Parse error: syntax error, unexpected T_VARIABLE in /.../plugins/insert-php/
   insert_php.php(48) : eval()’d code on line 3`
 * Am I doing something wrong?
 * [http://wordpress.org/plugins/insert-php/](http://wordpress.org/plugins/insert-php/)

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

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/#post-4204633)
 * Hi grimerking,
 * It’s a common misconception and I’ll have to rewrite the instructions page to
   make it clearer.
 * While Inert PHP is a plugin, it runs only PHP code that would run on a page independent
   of WordPress. In other words, it doesn’t have access to WordPress-specific functions.
 * Thus, neither get_post() nor apply_filters() will run within Insert PHP.
 * An independent MySQL connection with PHP mysqli…() functions to retrieve the 
   content of certain tables should work. You may need to write your own filter 
   function as a substitute to apply_filters().
 * Putting the PHP code into a separate web page and running it in the browser may
   be easier than debugging with the Insert PHP plugin. The error messages are likely
   to be more pertinent. After it runs independently, it should run OK with the 
   Insert PHP plugin.
 * Will
 *  Thread Starter [grimerking](https://wordpress.org/support/users/grimerking/)
 * (@grimerking)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/#post-4204636)
 * Hi Will,
 * Thanks for taking the time to provide support.
 * To be honest, that solution is beyond my skill-set at the moment – maybe something
   I’ll come back to in a few months time.
 * Rob
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/#post-4204790)
 * Gratuitous post to mark thread resolved.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/#post-4204791)
 * Gratuitous post to mark thread resolved.

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

The topic ‘Parse error: syntax error, unexpected T_VARIABLE in’ is closed to new
replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-unexpected-t_variable-in-1/#post-4204791)
 * Status: resolved