Ready to get started?Download WordPress


Allow PHP in a post Plugin Error..? (8 posts)

  1. jas001
    Posted 1 year ago #

    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

  2. Simon Prosser
    Theme Review Admin
    Posted 1 year ago #

    What code did you try and insert?

  3. jas001
    Posted 1 year ago #

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

    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>
            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='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..


  4. Simon Prosser
    Theme Review Admin
    Posted 1 year ago #

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

  5. jas001
    Posted 1 year ago #

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

    Thanks agian

  6. jas001
    Posted 1 year ago #

    Can i delete the code above..?

  7. Simon Prosser
    Theme Review Admin
    Posted 1 year ago #

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

  8. jas001
    Posted 1 year ago #

    Thanks for your kindness simon,,,

Topic Closed

This topic has been closed to new replies.

About this Topic