$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);                          //fetch result    
  mysql_close( $con ); 
$connection = mysql_connect("","root","causealmedus-1608");
if (!$connection)
  die('Could not connect: ' . mysql_error());
mysql_select_db("foresight", $connection);

$sql="INSERT INTO userinfo ('email')
('" . $email['email'] . "')";
if (!mysql_query($sql,$connection))
  die('Error: ' . mysql_error());
echo $email;

 //and using connection of localhost you have to update same record with status 1 at localhost. 


i face the following error:Could not connect: No connection could be made because the target machine actively refused it. 
4 Years
Discussion Span
Last Post by veedeoo

If the remote mysql server is running on linux, you must grant this user the permission as "GRANT ALL". Please consult the msyql documentation for this. If you are currently using a cpanel or WHM VPS manager, you can also set it there. Also on cpanel, there is also an option there under the mysql section.

I am not sure if this is valid IP "" for mysql connection though. If I can still recall it, it was something like this IP:PORT_NUMBER. It all depends on how the remote server was setup, your IP might be the only one needed. To find out more about this topic, please read it here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.