Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $remoteservername = "203.215.173.200";
- $remoteusername = "root";
- $remotepassword = "";
- $remotedatabase = "remotelwmc";
- // Create connection for remote database
- $connRemote = mysqli_connect($remoteservername, $remoteusername, $remotepassword, $remotedatabase);
- // Check connection for remote database
- if ($connRemote->connect_error) {
- die("Connection failed: " . $connRemote->connect_error);
- }
- else {
- echo "Remote database connected successfully"."<br>";
- }
- $localservername = "localhost";
- $localusername = "sa";
- $localpassword = "shanty";
- $localdatabase = "VTCS_New";
- // Create connection for local database
- $connectionInfo = array( "Database"=>$localdatabase, "UID"=>$localusername,
- "PWD"=>$localpassword);
- $connLocal = sqlsrv_connect($localservername, $connectionInfo);
- // Check connection for local database
- if ($connLocal->connect_error) {
- die("Connection failed: " . $connLocal->connect_error);
- }
- else {
- echo "Local database connected successfully"."<br>";
- }
- // For dbo.trips table
- $sql = "SELECT * FROM `dbo.trips` WHERE `flag` = 0";
- $result = mysqli_query($connRemote, $sql);
- $num_of_rows = mysqli_num_rows($result);
- if($num_of_rows > 0)
- {
- echo 'true1'."<br>";
- while ($row = mysqli_fetch_array($result))
- {
- $trip_id = $row['Trip_Id'];
- $fk_vehicle_id = $row['FK_Vehicle_Id'];
- $in_weight = $row['In_Weight'];
- $in_DateTime = $row['In_DateTIme'];
- $in_picture = $row['In_Picture'];
- $out_weight = $row['Out_Weight'];
- $out_DateTime = $row['Out_DateTIme'];
- $out_picture = $row['Out_Picture'];
- $site = $row['Site'];
- $pending = $row['Pending'];
- $createdDateTime = $row['CreatedDateTime'];
- $modifiedDateTime = $row['ModifiedDateTime'];
- echo $in_weight;
- $params = array(2,2,2,2,2,2,2,2,2,2,2,2);
- //(?,?,?,?,?,?,?,?,?,?,?,?)
- $sql1 = "INSERT INTO dbo.trips
- (Trip_Id, FK_Vehicle_Id, In_Weight, In_DateTIme, In_Picture, Out_Weight, Out_DateTIme, Out_Picture, Site, Pending, CreatedDateTime, ModifiedDateTime) VALUES
- (?,?,?,?,?,?,?,?,?,?,?,?)";
- $result1 = sqlsrv_query($connLocal, $sql1, $params);
- echo $result1."Hello"."<br>";
- if($result1)
- {
- echo 'true2'."<br>";
- $flagresult;
- do
- {
- //echo 'flag value into 1'."<br>";
- $sql2 = "UPDATE `dbo.trips` SET flag = 1 WHERE Trip_Id = $trip_id";
- $result2 = mysqli_query($connRemote, $sql2);
- if($result2)
- {
- echo 'true3'."<br>";
- $flagresult = 'true';
- }
- else
- {
- echo 'false3'."<br>";
- $flagresult = 'false';
- }
- }
- while($flagresult != 'true');
- }
- else
- {
- echo 'false2'."<br>";
- }
- }
- }
- else
- {
- echo 'false1';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement