<?php 
  $host = "localhost";
  $user = "root";
  $pass = "";
  $databaseName = "foresight";
  $tableName = "userinfo";
  $con = mysql_connect($host,$user,$pass);
  $dbs = mysql_select_db($databaseName, $con);
  $result = mysql_query("SELECT * FROM $tableName where flag != 1");          //query
  $email = mysql_fetch_row($result);  
  mysql_close();                        //fetch result    
?>
<?
  $host = '192.232.240.245';
  $user = 'root';
  $pass = 'nileshbhanushali';
  $conn = mysql_connect($host, $user, $pass);
  if(! $conn )
    {
   die('Could not connect: ' . mysql_error());
      }
   $sql = "INSERT INTO userinfo ".
   "(email) ".
   "VALUES ".
   "('$email')";
    mysql_select_db('foresight');
    $retval = mysql_query( $sql, $conn );
    if(! $retval )
     {
    die('Could not enter data: ' . mysql_error());
     }
     else
     {
     echo "enter succesfully";
}
mysql_close();


?>

but this code select data from localhost database but not insert in to server database?can anybody please give me some suggestion

first
change your password on your remote server.
Don't post it again!

2e
you forget to select the databaseon the remote, you do on localhost

3e mysql is deprecated. check out MySQLi or PDO_MySQL

password i have already change,and i have also select database in remote you can see at line no 26 but i did not get your 3 point

please buddy help me it's very urgent.....

Member Avatar

Please stop bumping this thread - 4 times within an hour? That's not cool. The fact that it's urgent is of no concern to us. We all have lives outside Daniweb and contribute when we can.

What don't you understand abut the 3rd point? mysql_* functions are deprecated and you should use mysqli_* functions or PDO.