0
<?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

3
Contributors
7
Replies
20
Views
3 Years
Discussion Span
Last Post by diafol
0

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

0

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

0

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.

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.