Guest User

Untitled

a guest
Oct 30th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. //Tablet DB Connection Infos
  2. $servername = "host1";
  3. $username = "user1";
  4. $password = "pw1";
  5. $dbname = "db1";
  6.  
  7. //Intra DB Connection Infos
  8. $servername2 = "host2";
  9. $username2 = "user2";
  10. $password2 = "pw2";
  11. $dbname2 = "db2";
  12.  
  13.  
  14. // Create connection
  15. $conn = mysqli_connect($servername, $username, $password, $dbname);
  16. // Check connection
  17. if (!$conn) {
  18. die("Connection to DB1 failed: " . mysqli_connect_error());
  19. }
  20.  
  21. $sql = "SELECT * FROM form WHERE exists = 0";
  22. $result = mysqli_query($conn, $sql);
  23.  
  24. //INSERT
  25. if (mysqli_num_rows($result) > 0) {
  26.  
  27. //connect to DB2
  28. $conn2 = mysqli_connect($servername2, $username2, $password2, $dbname2);
  29. if (!$conn2) {
  30. die("Connection to DB2 failed: " . mysqli_connect_error());
  31. }
  32.  
  33. while($row = mysqli_fetch_assoc($result)) {
  34.  
  35. $sqlInsert = "INSERT INTO `formulario` (`ID_FORM`,`ID_PICTURE`, `PICTURE`
  36. VALUES ($row[ID_FORM],$row[ID_PICTURE].$row[PICTURE]);";
  37.  
  38. }
  39. mysqli_close($conn2);
  40.  
  41.  
  42. } else {
  43. echo "0 records! <br />";
  44. }
  45.  
  46. mysqli_close($conn);
Add Comment
Please, Sign In to add comment