i wrote this script <?php /* Plugin Name: CronD Plugin URI: http://localhost Description: plugin that atutomates adult videos to ur blog Date: January, 26th, 2009 Author: AviAtriX Author URI: n/a Version: 1 */ function dbconnect ($host , $user , $pass , $db ) { $db_connect = @mysql_connect($host , $user , $pass); $db_select = @mysql_select_db($db); if (!$db_connect) { die ("cant connect to server error 1"); } else if (!$db_select) { die ("cant selcet db error 2"); } } $id =0; Function get_start_post(){ $query = "Select last from progres where id=1 "; $t1 = mysql_query($query); $t2 = mysql_fetch_array($t1); return $t2['last']; } Function get_last_post(){ $query = "Select tt from progres where id=1 "; $t1 = mysql_query($query); $t2 = mysql_fetch_array($t1); return $t2['tt']; } Function get_update_post($num){ $query = "update progres set last = '$num' where id = 1 "; $t1 = mysql_query($query) or die(mysql_error()); } function insert_post($id) { // Create post object GLOBAL $wpdb; Global $url_code; $video_code = $wpdb->get_var("Select code From data Where id='$id' limit 1 "); $url_code = $wpdb->get_var("Select thumb From data Where id='$id' limit 1 "); $video_title = $wpdb->get_var("Select titel From data Where id='$id' limit 1 "); $content = '[redtube]' . $video_code . '[/redtube]'; $my_post = array(); $my_post['post_title'] = $video_title; $my_post['post_content'] = $content; $my_post['post_status'] = 'publish'; $my_post['post_author'] = 1; $my_post['post_category'] = array(1); // Insert the post into the database wp_insert_post( $my_post ); } function parse_code($id) { $post = mysql_query("Select post_content From wp_posts Where id='$id' limit 1 ") or die(mysql_error()); $post1 = mysql_fetch_array($post) or die(mysql_error()); $content = explode("<p>", $post1); $search = array('[redtube]', '</p>' , '[/redtube]'); $replace = ''; $subject = $content[3]; $pesho = str_replace($search, $replace, $subject); $thumb = mysql_query("Select thumb From data Where code='$pesho' limit 1 ")or die(mysql_error()); $thumb2 = mysql_fetch_array($thumb) or die(mysql_error()); $x1 = $thumb2['thumb']; return $x1; } function insert_meta($post_id,$meta_value){ add_post_meta($post_id,'thumbs', $meta_value ,true ); } function ssss(){ $query = "Select ID From wp_posts ORDER BY ID DESC LIMIT 1 "; $t1 = mysql_query($query); $t2 = mysql_fetch_array($t1); return $t2['last']; } if (get_start_post() === get_last_post() ){ exit(1); } else { while (get_start_post() <= get_last_post() ) { insert_post(get_start_post()); insert_meta(ssss(), $url_code ); $start= get_start_post(); $start++; get_update_post($start); } } ?> PHP: but the Insert_meta function works only when is used liek this insert_meta(get_start_post(), $url_code ); PHP: and not like i need it insert_meta(ssss(), $url_code ); PHP: any help is apreciated thanks in advance