Insert data into remote server database

Hello friends !! Want to insert data into remote server. Here you are at right place. Just follow these simple steps.

    1. Make ftp connection with remote server.
    2. Login with remote server username and Password.
    3. Make database connection with with remote server database.
    4. Write simple insert query.

Here is the Code :

  //Change this
   
  $server   =  'example.com';
  $ftp_user =  'username';
  $ftp_pwd  =  'password';

  $host     =  'localhost';
  $db_user  =  'username';
  $db_pwd   =  'password';

  //Login to remote server

  $ftp = ftp_connect($server);
  ftp_login($ftp, $ftp_user, $ftp_pwd);

  //Make database Connection

  $link = mysql_connect($host, $db_user, $db_pwd);
  mysql_select_db("database-name", $link);

  //Write insert query

  $sql="insert into tablename set field1='value1', 
        field2='value2' , field3='value3'";
  mysql_query($sql);


Above query will insert data into remote server database.
Insert data into remote server database Insert data into remote server database Reviewed by Altaf Hussain on 1:09 PM Rating: 5

No comments:

Altaf Web. Powered by Blogger.