Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. <?php
  2. $remoteservername = "203.215.173.200";
  3. $remoteusername = "root";
  4. $remotepassword = "";
  5. $remotedatabase = "remotelwmc";
  6.  
  7. // Create connection for remote database
  8. $connRemote = mysqli_connect($remoteservername, $remoteusername, $remotepassword, $remotedatabase);
  9.  
  10. // Check connection for remote database
  11. if ($connRemote->connect_error) {
  12. die("Connection failed: " . $connRemote->connect_error);
  13. }
  14. else {
  15. echo "Remote database connected successfully"."<br>";
  16. }
  17.  
  18. $localservername = "localhost";
  19. $localusername = "sa";
  20. $localpassword = "shanty";
  21. $localdatabase = "VTCS_New";
  22.  
  23. // Create connection for local database
  24. $connectionInfo = array( "Database"=>$localdatabase, "UID"=>$localusername,
  25. "PWD"=>$localpassword);
  26. $connLocal = sqlsrv_connect($localservername, $connectionInfo);
  27.  
  28. // Check connection for local database
  29. if ($connLocal->connect_error) {
  30. die("Connection failed: " . $connLocal->connect_error);
  31. }
  32. else {
  33. echo "Local database connected successfully"."<br>";
  34. }
  35.  
  36. // For dbo.trips table
  37.  
  38. $sql = "SELECT * FROM `dbo.trips` WHERE `flag` = 0";
  39. $result = mysqli_query($connRemote, $sql);
  40. $num_of_rows = mysqli_num_rows($result);
  41. if($num_of_rows > 0)
  42. {
  43. echo 'true1'."<br>";
  44. while ($row = mysqli_fetch_array($result))
  45. {
  46. $trip_id = $row['Trip_Id'];
  47. $fk_vehicle_id = $row['FK_Vehicle_Id'];
  48. $in_weight = $row['In_Weight'];
  49. $in_DateTime = $row['In_DateTIme'];
  50. $in_picture = $row['In_Picture'];
  51. $out_weight = $row['Out_Weight'];
  52. $out_DateTime = $row['Out_DateTIme'];
  53. $out_picture = $row['Out_Picture'];
  54. $site = $row['Site'];
  55. $pending = $row['Pending'];
  56. $createdDateTime = $row['CreatedDateTime'];
  57. $modifiedDateTime = $row['ModifiedDateTime'];
  58.  
  59. echo $in_weight;
  60. $params = array(2,2,2,2,2,2,2,2,2,2,2,2);
  61. //(?,?,?,?,?,?,?,?,?,?,?,?)
  62.  
  63. $sql1 = "INSERT INTO dbo.trips
  64. (Trip_Id, FK_Vehicle_Id, In_Weight, In_DateTIme, In_Picture, Out_Weight, Out_DateTIme, Out_Picture, Site, Pending, CreatedDateTime, ModifiedDateTime) VALUES
  65. (?,?,?,?,?,?,?,?,?,?,?,?)";
  66. $result1 = sqlsrv_query($connLocal, $sql1, $params);
  67. echo $result1."Hello"."<br>";
  68. if($result1)
  69. {
  70. echo 'true2'."<br>";
  71. $flagresult;
  72. do
  73. {
  74. //echo 'flag value into 1'."<br>";
  75. $sql2 = "UPDATE `dbo.trips` SET flag = 1 WHERE Trip_Id = $trip_id";
  76. $result2 = mysqli_query($connRemote, $sql2);
  77.  
  78. if($result2)
  79. {
  80. echo 'true3'."<br>";
  81. $flagresult = 'true';
  82. }
  83. else
  84. {
  85. echo 'false3'."<br>";
  86. $flagresult = 'false';
  87. }
  88. }
  89. while($flagresult != 'true');
  90. }
  91. else
  92. {
  93. echo 'false2'."<br>";
  94. }
  95. }
  96.  
  97. }
  98. else
  99. {
  100. echo 'false1';
  101. }
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement