I recently deployed a new application to a local Ubuntu server, but the program is missing a lot of functionality that was originally coded in the scripts.
The program was originally built in XAMPP but was deployed to Linux.
This import functionality is a good example.
<?php
include('dbconnect.php');
if(isset($_POST['btn_upload'])){
$filename = $_FILES['file']['tmp_name'];
$file = fopen($filename,"r");
// Read and throw away the header row
fgetcsv($file);
$stmt = $pdo->prepare("INSERT INTO invoices (id, Invoice_Number, Customer_Number, Customer_Name, Invoice_Date, Sales_Order_Number, Sales_Amount, Progress_Billing, Extra_Charge_Amount, Tax_Amount, Invoice_Amount, Writeoff_Amount, Paid_Amount, Balance_Due, Use_Tax, Tax_Stat, Salesperson_1, Comm_Rate_1, Salesperson_2, Comm_Rate_2, Salesperson_3, Comm_Rate_3, Deposit_Applied, Sales_Tax_Codes, Sales_Tax_Amounts, Customer_Address1, Customer_Address2, Customer_City, Customer_State, Customer_Zip, Customer_Country) VALUES (:id, :Invoice_Number, :Customer_Number, :Customer_Name, :Invoice_Date, :Sales_Order_Number, :Sales_Amount, :Progress_Billing, :Extra_Charge_Amount, :Tax_Amount, :Invoice_Amount, :Writeoff_Amount, :Paid_Amount, :Balance_Due, :Use_Tax, :Tax_Stat, :Salesperson_1, :Comm_Rate_1, :Salesperson_2, :Comm_Rate_2, :Salesperson_3, :Comm_Rate_3, :Deposit_Applied, :Sales_Tax_Codes, :Sales_Tax_Amounts, :Customer_Address1, :Customer_Address2, :Customer_City, :Customer_State, :Customer_Zip, :Customer_Country)");
while (! feof($file)) {
$row = fgetcsv($file);
if($row[0] == NULL) {
continue;
}
$stmt->bindParam(':id', $row[0]);
$stmt->bindParam(':Invoice_Number', $row[1]);
$stmt->bindParam(':Customer_Number', $row[2]);
$stmt->bindParam(':Customer_Name', $row[3]);
$date = date_create($row[4]);
$dfstr = date_format($date, 'Y-m-d');
$stmt->bindParam(':Invoice_Date', $dfstr);
$stmt->bindParam(':Sales_Order_Number', $row[5]);
$stmt->bindParam(':Sales_Amount', $row[6]);
$stmt->bindParam(':Progress_Billing', $row[7]);
$stmt->bindParam(':Extra_Charge_Amount', $row[8]);
$stmt->bindParam(':Tax_Amount', $row[9]);
$stmt->bindParam(':Invoice_Amount', $row[10]);
$stmt->bindParam(':Writeoff_Amount', $row[11]);
$stmt->bindParam(':Paid_Amount', $row[12]);
$stmt->bindParam(':Balance_Due', $row[13]);
$stmt->bindParam(':Use_Tax', $row[14]);
$stmt->bindParam(':Tax_Stat', $row[15]);
$stmt->bindParam(':Salesperson_1', $row[16]);
$stmt->bindParam(':Comm_Rate_1', $row[17]);
$stmt->bindParam(':Salesperson_2', $row[18]);
$stmt->bindParam(':Comm_Rate_2', $row[19]);
$stmt->bindParam(':Salesperson_3', $row[20]);
$stmt->bindParam(':Comm_Rate_3', $row[21]);
$stmt->bindParam(':Deposit_Applied', $row[22]);
$stmt->bindParam(':Sales_Tax_Codes', $row[23]);
$stmt->bindParam(':Sales_Tax_Amounts', $row[24]);
$stmt->bindParam(':Customer_Address1', $row[25]);
$stmt->bindParam(':Customer_Address2', $row[26]);
$stmt->bindParam(':Customer_City', $row[27]);
$stmt->bindParam(':Customer_State', $row[28]);
$stmt->bindParam(':Customer_Zip', $row[29]);
$stmt->bindParam(':Customer_Country', $row[30]);
$stmt->execute();
}
fclose($file);
header("Location: ../invoices_list.php");
}
if(isset($_POST['btn_back'])) {
header("Location: ../invoices_list.php");
}
?>
When I run the code through XAMPP, it works properly and imports the spreadsheet. However, when I do the same thing on the local server, I get an HTTP 500 error which tells me nothing.
I tried enabling PHP errors in the php.ini file, and they do not work. Iāve changed the dbconnect file to have the correct password to connect to the database. I know it is working (somehow) because I can create and remove new users when I need to on the local server, but I canāt make reports or import new data files.
What do I do to get the code working again?