Support » Themes and Templates » 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/ : 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


    Theme Review Admin

    What code did you try and insert?

    [ 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 instead. ]

    code for XML

    //Customize here...
        $pubID = "579917657152129";
        $niche = "health care administration";
        $state = "arizona";
        $img = "";
    //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 = "";
        $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="$nicheUgly&l=&indpubnum=$pubID">View ALL $nicheNice job listings</a></div>
            if ($i == 9){
              echo <<<x
    <div style="text-align:center; padding:5px 0 5px 0; height:175px;"><img src="$img"></div>
            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>
          } else {
        if ($i >= 2){
          echo "<div style='margin:10px 0 10px 0; font-weight:bold; font-size:14px;'>» <a href='$nicheUgly&l=&indpubnum=$pubID'>View more $nicheNice job listings</a></div><div style='text-align:right;'><span id=indeed_at><a href=''>jobs</a> by <a href='' title='Job Search'><img src='' 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..


    Simon Prosser


    Theme Review Admin

    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));

    Oh, Thank your very much Mr. Simon its working…

    Thanks agian

    Can i delete the code above..?

    Simon Prosser


    Theme Review Admin

    Im sure a moderator might do that for you, i tagged it so they see it.

    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.