The new_to_publish
hook has one argument: $post
. Use that to get the post id. Here is your editted code:
add_action( 'new_to_publish', 'send_notification', 1, 1 );
function send_notification( $post ){
$post_id = $post->ID;;
global $wpdb;
$sel2 = mysql_query("select * from gcm_users");
while($data1 = mysql_fetch_assoc($sel2))
{
$key = $data1['gcm_regid'];
include_once '../blogdroid/config.php';
include_once '../blogdroid/GCM.php';
$gcm = new GCM();
$sel = mysql_query("select * from ".$wpdb->prefix."posts where ID='$post_id'");
$data = mysql_fetch_assoc($sel);
$Pname = $data['post_title'];
$registatoin_ids = array($key);
if($Pname != 'Auto Draft')
{
$message = array("blog" => 'New Blog Arrived '.$Pname );
$result = $gcm->send_notification($registatoin_ids,$message);
}
}
}
}