Title: Allow PHP in a post Plugin Error..?
Last modified: August 20, 2016

---

# Allow PHP in a post Plugin Error..?

 *  [jas001](https://wordpress.org/support/users/jas001/)
 * (@jas001)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/)
 * Hi everybody, i need help!
    I’m using allow PHP Plugin in a post, when i update
   to a latest version, i got this error in my post..
 * Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing 
   to repeat at offset 0 in /home/jasni/public_html/careerneeds.net/new-jobs-listing/
   wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(373) : eval()’d 
   code on line 7
 * Can you all help, i have no idea how to solve this.
 * Thanks in advance

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

 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055600)
 * What code did you try and insert?
 *  Thread Starter [jas001](https://wordpress.org/support/users/jas001/)
 * (@jas001)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055624)
 * _[ Moderator Note: Please post code or markup snippets between backticks or use
   the code button. As it stands, your code may now have been permanently damaged/
   corrupted by the forum’s parser. [Or use pastebin.com instead](http://codex.wordpress.org/Forum_Welcome#Posting_Code).]_
 * code for indeed.com XML
 *     ```
       //Customize here...
           $pubID = "579917657152129";
           $niche = "health care administration";
           $state = "arizona";
           $img = "http://jobboards.jobstar.info/wp-content/uploads/2012/05/hiring1.png";
       //Don't edit below here...
           $nicheNice = ucwords(preg_replace("/+/", " ", $niche));
           $nicheUgly = preg_replace("/ /", "+", $niche);
           $userip = $_SERVER['REMOTE_ADDR'];
           $useragent = urlencode($_SERVER['HTTP_USER_AGENT']);
           $toGet = "http://api.indeed.com/ads/apisearch?";
           $inputdata = array();
           $inputdata[] = "publisher=$pubID";
           $inputdata[] = "v=2";
           $inputdata[] = "format=xml";
           $inputdata[] = "callback=";
           $inputdata[] = "q=$nicheUgly";
           $inputdata[] = "l=$state";
           $inputdata[] = "sort=relevance";
           $inputdata[] = "radius=25";
           $inputdata[] = "st=";
           $inputdata[] = "jt=";
           $inputdata[] = "start=0";
           $inputdata[] = "limit=11";
           $inputdata[] = "fromage=30";
           $inputdata[] = "highlight=0";
           $inputdata[] = "filter=1";
           $inputdata[] = "latlong=";
           $inputdata[] = "co=us";
           $inputdata[] = "chnl=";
           $inputdata[] = "userip=$userip";
           $inputdata[] = "useragent=$useragent";
           $query = implode("&", $inputdata);
           $jobs = simplexml_load_file($toGet.$query);
   
           $jobDetails = array('Job','Work','Career Opportunity','Hiring','Work','Hiring','Hiring','Job Opportunity','Work','Hiring','Hiring','Job Opportunity','Career Opportunity','Local Job','Job Opportunity','New Job');
           $i = "1";
   
           foreach ($jobs->results->result as $jobinfo){
             if ($i <= "10"){
               $title = $jobinfo->jobtitle;
               $company = $jobinfo->company;
               $snippet = ucfirst($jobinfo->snippet);
               $loc = $jobinfo->formattedLocationFull;
               $jobCity = $jobinfo->city;
               $jobState = $jobinfo->state;
               $jobkey = $jobinfo->jobkey;
               $jobURL = $jobinfo->url;
               $jobDetail = $jobDetails[$i];
               if ($i == 1){
                 $jobDetailMargin = "margin:0 0 10px 0;";
               } else {
                 $jobDetailMargin = "margin:15px 0 15px 0;";
               }
   
               if ($i == 1){
                 echo <<<x
       <div style="margin:10px 0 10px 0; font-weight:bold; font-size:14px;">» <a href="http://www.indeed.com/jobs?q=$nicheUgly&l=&indpubnum=$pubID">View ALL $nicheNice job listings</a></div>
       x;
               }
   
               if ($i == 9){
                 echo <<<x
       <div style="text-align:center; padding:5px 0 5px 0; height:175px;"><img src="$img"></div>
       x;
               }
   
               echo <<<x
       <div style="$jobDetailMargin line-height:18px; border:solid 1px #cccccc; background:#f5f5f5; padding:5px 10px 5px 10px;">
         <div><strong><a href="$jobURL">$title</a></strong></div>
         <div><b>Located in $loc.</b> $jobDetail Details: $snippet</div>
         <div style="color:#3A8041; font-size:11px;">Employer: $company</div>
       </div>
       x;
               $i++;
             } else {
               break;
             }
           }
           if ($i >= 2){
             echo "<div style='margin:10px 0 10px 0; font-weight:bold; font-size:14px;'>» <a href='http://www.indeed.com/jobs?q=$nicheUgly&l=&indpubnum=$pubID'>View more $nicheNice job listings</a></div><div style='text-align:right;'><span id=indeed_at><a href='http://www.indeed.com/'>jobs</a> by <a href='http://www.indeed.com/' title='Job Search'><img src='http://www.indeed.com/p/jobsearch.gif' style='border: 0; vertical-align: middle;' alt='Indeed job search' title='Job Search'></a></span></div>";
           } else {
             echo "<div><strong>No jobs found.</strong> Please broaden your search...</div>";
           }
       ```
   
 * any suggestions..
 * Thanks
 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055627)
 * Im sure pastebin might have been a better choice than just pasting it in here,
   the forum makes it unreadable.
 * Anyway id put all that in a shortcode or something…
 * Line 7:
    `$nicheNice = ucwords(preg_replace("/+/", " ", $niche));`
 * your expression is basically + and + in PCRE means repeat. so repeat nothing!
   If you want it to match the + you need to escape it:
    `$nicheNice = ucwords(preg_replace("/\
   +/", " ", $niche));`
 *  Thread Starter [jas001](https://wordpress.org/support/users/jas001/)
 * (@jas001)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055631)
 * Oh, Thank your very much Mr. Simon its working…
 * Thanks agian
 *  Thread Starter [jas001](https://wordpress.org/support/users/jas001/)
 * (@jas001)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055633)
 * Can i delete the code above..?
 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055634)
 * Im sure a moderator might do that for you, i tagged it so they see it.
 *  Thread Starter [jas001](https://wordpress.org/support/users/jas001/)
 * (@jas001)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055673)
 * Thanks for your kindness simon,,,

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

The topic ‘Allow PHP in a post Plugin Error..?’ is closed to new replies.

 * 7 replies
 * 2 participants
 * Last reply from: [jas001](https://wordpress.org/support/users/jas001/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/allow-php-in-a-post-plugin-error/#post-3055673)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
