HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/fieldsblaze-heroku/cron/customer-name-update.php
<?php
$servername = "localhost";
$username = "root";
$password = "cloudcentric!@#$";
$dbname = "fsa_dev";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT CustomerId, CustomerName FROM `tbl_order` ORDER BY `id` DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
  // output data of each row
  while($row = $result->fetch_assoc()) {
    $CustomerId = $row["CustomerId"];
    $CustomerName = $row["CustomerName"];

    if($CustomerId)
    {
        $sqlCustomer = "SELECT CustomerId, CustomerName FROM `tbl_customer` where CustomerId = '$CustomerId' ORDER BY `id` DESC";
        $resultCustomer = $conn->query($sqlCustomer);
        if ($resultCustomer->num_rows > 0) {
        // output data of each row
            $rowCustomer = $resultCustomer->fetch_assoc();
            {
                $CustomerId = $rowCustomer["CustomerId"];
                $CustomerName = $rowCustomer["CustomerName"];
            }
        }
    }
   
    $sqlUpdate = "UPDATE tbl_order set CustomerName = '".$CustomerName."' where CustomerId = '".$CustomerId."'";
    if ($conn->multi_query($sqlUpdate) === TRUE) 
    {
        $success_error = "Updated successfully";
    } 
    else 
    {
        $success_error =  "Error: " . $sqlUpdate . "<br>" . $conn->error;
    }

    echo "Id = ".$CustomerId."--- Name =".$CustomerName.", success_error = ".$success_error."  <br/>";


  }
} else {
  echo "0 results";
}
$conn->close();