Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:57:44+00:00 2026-06-01T23:57:44+00:00

i m using the php code to exectue the code using the cron. i

  • 0

i m using the php code to exectue the code using the cron. i have set the cron time and command in cpanel also.

1). But whenever cron runs i receive a mail

/home/letsview/public_html/getfeed.php: line 1: ?php: No such file or directory
/home/letsview/public_html/getfeed.php: line 3: syntax error near unexpected token `'/home/letsview/public_html/wp-config.php''
/home/letsview/public_html/getfeed.php: line 3: `include_once('/home/letsview/public_html/wp-config.php');'

i have set this command in cpanel "/home/letsview/public_html/getfeed.php"

i have also tried this PHP: Error trying to run a script via Cron job and added this command on the top of the file /usr/local/lib/php/ but it still not working

Here is the code of cron file getfeed.php

<?php
#!/usr/local/lib/php/
include_once('/home/letsview/public_html/wp-config.php');
include_once('/home/letsview/public_html/wp-includes/wp-db.php');
include_once('/home/letsview/public_html/wp-admin/includes/file.php');          
include_once('/home/letsview/public_html/wp-admin/includes/image.php');         
include_once('/home/letsview/public_html/wp-admin/includes/media.php');
global $wpdb;
 //property_type
$xml = simplexml_load_file("/home/letsview/public_html/letsviewproperties.xml",'SimpleXMLElement', LIBXML_NOCDATA);
$TotalPostadded = 0;
$TotalUseradded = 0;
foreach($xml as $child)
{
    //Insert Post
    $postdata = array();
    $postdata['post_title'] = trim($child->title);
    $postdata['post_content'] = trim($child->content);
    //$postdata['guid'] = trim($child->url);
    $postdata['post_status'] = 'publish';
    $postdata['post_type'] = 'post';
    $postdata['post_date'] = date('Y-m-d H:i:s');

    //Insert Post Meta
    $postmetadata = array();
    $addresstext = trim($child->FullAddress->address1);
    if($addresstext != ''){
        $addresstext .= ', ';
    }
    $addresstext .= trim($child->FullAddress->address2);
    if($addresstext != ''){
        $addresstext .= ', ';
    }
    $addresstext .= trim($child->FullAddress->address3);
    if($addresstext != ''){
        $addresstext .= ', ';
    }
    $addresstext .= trim($child->FullAddress->address4);
    $postmetadata['price'] = trim($child->price);
    $postmetadata['property_type'] = trim($child->type);
    $postmetadata['bed_rooms'] = trim($child->rooms);
    $postmetadata['bath_rooms'] = trim($child->bathrooms);
    $postmetadata['address'] = $addresstext;
    $postmetadata['add_city'] = trim($child->city);
    $postmetadata['add_state'] = trim($child->FullAddress->region);
    $postmetadata['add_country'] = trim($child->FullAddress->country);
    $postmetadata['add_zip_code'] = trim($child->postcode);
    $postmetadata['other_guid'] = trim($child->url);
    $postmetadata['post_from_feed'] = true;

    //Insert Author(agent)
    $authordata = array();
    $authormetadata = array();
    if(!empty($child->agent->agent_name)){
        //Author data
        $authordata['user_login'] = trim(pg_create_string($child->agent->agent_name));
        $authordata['user_nicename'] = trim($child->agent->agent_name);
        $authordata['display_name'] = trim($child->agent->agent_name);
        $authordata['user_email'] = trim($child->agent->agent_email);
        $authordata['user_url'] = trim($child->url);
        $authordata['role'] = trim('agent');
        $authordata['user_registered'] = date('Y-m-d H:i:s');
        //Author meta data
        $authormetadata['user_phone'] = trim($child->agent->agent_phone);
        $authormetadata['user_address'] = trim($child->agent->agent_address);
    }
    foreach($child->pictures as $pictures)
    {
        $postimagedata = array();
        $imageloop = 0;
        foreach($pictures as $picture)
        {
            $postimagedata[$imageloop] = (string)$picture->picture_url;
            $imageloop++;
        }
    }
    $postmetadata['post_from_feed_images'] = serialize($postimagedata);
    if($postdata['post_title'] != ''){
        $sql = "select count(post_title) as post from ".$wpdb->prefix."posts  where post_title = '".$postdata['post_title']."' and post_status = '".$postdata['post_status']."'";
        $sqlresult = $wpdb->get_results($sql);
        foreach ( $sqlresult as $post ) { 
            if($post->post == 0)
            {
                if(!empty($authordata)){
                    $user_id = wp_insert_user( $authordata );

                    if(!empty($user_id) && empty($user_id->errors)){
                        $TotalUseradded++;
                        echo "User added = ".$user_id."<br />";
                        if(!empty($authormetadata)){
                            foreach($authormetadata as $meta_key=>$meta_value){
                                add_user_meta( $user_id, $meta_key, $meta_value);
                                echo "User Meta = ".$meta_key." Inserted<br />";
                            }
                        }
                    }elseif(!empty($user_id->errors)){
                        $userdata = get_user_by('email', $authordata['user_email']);
                        $user_id = $userdata->ID;
                        echo "User fetched = ".$user_id."<br />";
                    }
                    $postdata['post_author'] = $user_id;
                }
                $post_id = wp_insert_post($postdata);
                if(!empty($post_id)){
                    $TotalPostadded++;  
                    echo "<br />"."Post Inserted = ".$post_id;
                    $properties_category_id = 109;
                    $cat = "INSERT INTO wp_term_relationships ( object_id, term_taxonomy_id ) VALUES ( '".$post_id."','".$properties_category_id."' )";
                    $catid = $wpdb->query($cat);
                    echo "<br />"."Post attached to Category ID = ".$properties_category_id."<br />";
                    if(!empty($postmetadata)){
                        foreach($postmetadata as $key=>$value){
                            add_post_meta($post_id, $key,$value, true);
                            echo "Post Meta = ".$key." Inserted<br />";
                        }
                    }
                }   
            }
        }
    }
}
$cron = "<br />"."Corn Done";
$cron .= "<br />"."Total Post added = ".$TotalPostadded;
$cron .= "<br />Total User added = ".$TotalUseradded;
echo $cron;
mail('xxxxxx@xxxxx.com','Lets view Properties Corn',$cron);
function pg_create_string($text)
{
  // replace all non letters or digits with -
  $text = preg_replace('/\W+/', '-', $text);

  // trim and lowercase
  $text = strtolower(trim($text, '-'));
  return $text;
} 
?>

Can any one help me??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:57:46+00:00Added an answer on June 1, 2026 at 11:57 pm

    The start of the file should be:

    #!/usr/bin/php
    <?php
    

    This assumes that your PHP binary is in the folder /usr/bin. If it isn’t, then change the #! line appropriately.

    Even better:

    #!/usr/bin/env php
    <?php
    

    will almost certainly work as it uses the system’s env command to work out where php is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following PHP code for trigger creation but always get error, please
So I'm using the following php code to set variables that are received from
I am using php code to query to a database and the results will
How can I get last year's start and end date using PHP code? Is
How do I delete a file on the filesystem using PHP code? <?php if
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I'm currently using the following PHP code: // Get all subordinates $subords = array();
I'm trying to parse a php code using some regex and I'm stuck at
I'm accessing http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php using code generated by http://sudzc.com The SOAP message is being sent
My PHP code is split between many files, and often I find myself using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.