Note that there are some explanatory texts on larger screens.

plurals
  1. POphp cron job issue?
    primarykey
    data
    text
    <p>i m using the php code to exectue the code using the cron. i have set the cron time and command in cpanel also.</p> <p>1). But whenever cron runs i receive a mail</p> <pre><code>/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');' </code></pre> <p>i have set this command in cpanel <code>"/home/letsview/public_html/getfeed.php"</code></p> <p>i have also tried this <a href="https://stackoverflow.com/questions/3330804/php-error-trying-to-run-a-script-via-cron-job">PHP: Error trying to run a script via Cron job</a> and added this command on the top of the file <code>/usr/local/lib/php/</code> but it still not working</p> <p>Here is the code of cron file <code>getfeed.php</code></p> <pre><code>&lt;?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-&gt;title); $postdata['post_content'] = trim($child-&gt;content); //$postdata['guid'] = trim($child-&gt;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-&gt;FullAddress-&gt;address1); if($addresstext != ''){ $addresstext .= ', '; } $addresstext .= trim($child-&gt;FullAddress-&gt;address2); if($addresstext != ''){ $addresstext .= ', '; } $addresstext .= trim($child-&gt;FullAddress-&gt;address3); if($addresstext != ''){ $addresstext .= ', '; } $addresstext .= trim($child-&gt;FullAddress-&gt;address4); $postmetadata['price'] = trim($child-&gt;price); $postmetadata['property_type'] = trim($child-&gt;type); $postmetadata['bed_rooms'] = trim($child-&gt;rooms); $postmetadata['bath_rooms'] = trim($child-&gt;bathrooms); $postmetadata['address'] = $addresstext; $postmetadata['add_city'] = trim($child-&gt;city); $postmetadata['add_state'] = trim($child-&gt;FullAddress-&gt;region); $postmetadata['add_country'] = trim($child-&gt;FullAddress-&gt;country); $postmetadata['add_zip_code'] = trim($child-&gt;postcode); $postmetadata['other_guid'] = trim($child-&gt;url); $postmetadata['post_from_feed'] = true; //Insert Author(agent) $authordata = array(); $authormetadata = array(); if(!empty($child-&gt;agent-&gt;agent_name)){ //Author data $authordata['user_login'] = trim(pg_create_string($child-&gt;agent-&gt;agent_name)); $authordata['user_nicename'] = trim($child-&gt;agent-&gt;agent_name); $authordata['display_name'] = trim($child-&gt;agent-&gt;agent_name); $authordata['user_email'] = trim($child-&gt;agent-&gt;agent_email); $authordata['user_url'] = trim($child-&gt;url); $authordata['role'] = trim('agent'); $authordata['user_registered'] = date('Y-m-d H:i:s'); //Author meta data $authormetadata['user_phone'] = trim($child-&gt;agent-&gt;agent_phone); $authormetadata['user_address'] = trim($child-&gt;agent-&gt;agent_address); } foreach($child-&gt;pictures as $pictures) { $postimagedata = array(); $imageloop = 0; foreach($pictures as $picture) { $postimagedata[$imageloop] = (string)$picture-&gt;picture_url; $imageloop++; } } $postmetadata['post_from_feed_images'] = serialize($postimagedata); if($postdata['post_title'] != ''){ $sql = "select count(post_title) as post from ".$wpdb-&gt;prefix."posts where post_title = '".$postdata['post_title']."' and post_status = '".$postdata['post_status']."'"; $sqlresult = $wpdb-&gt;get_results($sql); foreach ( $sqlresult as $post ) { if($post-&gt;post == 0) { if(!empty($authordata)){ $user_id = wp_insert_user( $authordata ); if(!empty($user_id) &amp;&amp; empty($user_id-&gt;errors)){ $TotalUseradded++; echo "User added = ".$user_id."&lt;br /&gt;"; if(!empty($authormetadata)){ foreach($authormetadata as $meta_key=&gt;$meta_value){ add_user_meta( $user_id, $meta_key, $meta_value); echo "User Meta = ".$meta_key." Inserted&lt;br /&gt;"; } } }elseif(!empty($user_id-&gt;errors)){ $userdata = get_user_by('email', $authordata['user_email']); $user_id = $userdata-&gt;ID; echo "User fetched = ".$user_id."&lt;br /&gt;"; } $postdata['post_author'] = $user_id; } $post_id = wp_insert_post($postdata); if(!empty($post_id)){ $TotalPostadded++; echo "&lt;br /&gt;"."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-&gt;query($cat); echo "&lt;br /&gt;"."Post attached to Category ID = ".$properties_category_id."&lt;br /&gt;"; if(!empty($postmetadata)){ foreach($postmetadata as $key=&gt;$value){ add_post_meta($post_id, $key,$value, true); echo "Post Meta = ".$key." Inserted&lt;br /&gt;"; } } } } } } } $cron = "&lt;br /&gt;"."Corn Done"; $cron .= "&lt;br /&gt;"."Total Post added = ".$TotalPostadded; $cron .= "&lt;br /&gt;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; } ?&gt; </code></pre> <p>Can any one help me??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload