当我取消注释所有表插入并运行它时,我在第264行遇到了意外的文件结束错误。我无法弄明白,我已经检查过了,我认为所有的支架都在那里。我知道我的缩进不完全正确但我稍后会解决这个问题。
<?php
$servername = "servername";
$username = "username";
$password = "password";
$database = "database";
$con = mysqli_connect($servername,$username,$password,$database);
if($con->connect_error){
die("Connection failed " . $con->connect_error);
}
/*$sql = "DROP TABLE Employee";
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not delete table: ' . mysql_error());
}
echo "Table deleted successfully\n";
$sql = "DROP TABLE Department";
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not delete table: ' . mysql_error());
}
echo "Table deleted successfully\n";
$sql = "DROP TABLE Ticket_Main";
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not delete table: ' . mysql_error());
}
echo "Table deleted successfully\n";
$sql = "DROP TABLE Issue";
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not delete table: ' . mysql_error());
}
echo "Table deleted successfully\n";
$sql = "DROP TABLE TransAct";
$retval = mysqli_query( $con, $sql );
if(! $retval )
{
die('Could not delete table: ' . mysql_error());
}
echo "Table deleted successfully\n";
$ticket="CREATE TABLE Ticket_Main (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
request VARCHAR(255) NOT NULL,
priority VARCHAR(255) not null,
issue_id INT(11) not null,
date datetime not null,
author VARCHAR(255) not null,
complete bool not null
)";
if ($con->query($ticket) === TRUE) {
echo "Table test_table created successfully";
} else {
echo "Error creating table: " . $con->error;
}
$Issue="CREATE TABLE Issue (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
issue_name VARCHAR(255) not null,
issue_description VARCHAR(255) null,
department_id INT(11) not null
)";
if ($con->query($Issue) === TRUE) {
echo "Table test_table created successfully";
} else {
echo "Error creating table: " . $con->error;
}
$Department="CREATE TABLE Department (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Department_name VARCHAR(255) not null
)";
if ($con->query($Department) === TRUE) {
echo "Table test_table created successfully";
} else {
echo "Error creating table: " . $con->error;
}
$Employee="CREATE TABLE Employee (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) not null,
first VARCHAR(255) not null,
last VARCHAR(255) not null,
department_id INT(11) not null
)";
if ($con->query($Employee) === TRUE) {
echo "Table test_table created successfully";
} else {
echo "Error creating table: " . $con->error;
}
$TransAct="CREATE TABLE TransAct (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
date_time datetime,
Ticket_Main_id INT(11) not null,
iscomplete bool not null,
request_sender VARCHAR(255) not null,
request_receiver VARCHAR(255) not null
)";
if ($con->query($TransAct) === TRUE) {
echo "Table test_table created successfully";
} else {
echo "Error creating table: " . $con->error;
}*/
$insert1 = "insert into Issue (issue_name,department_id) values ('Shipping Discrepancy',6)"; //Logistics
$run_insert1 = mysqli_query($con,$insert1);
if($run_insert1){echo "Shipping Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert2 = "insert into Issue (issue_name, department_id) values ('Sales Discrepancy',3)"; //IT
$run_insert2 = mysqli_query($con,$insert2);
if($run_insert2){echo "Sales Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert3 = "insert into Issue (issue_name, department_id) values ('Program Glitch',3)"; //IT
$run_insert3 = mysqli_query($con,$insert3);
if($run_insert3){echo "Program Glitch inserted";}
else{echo "error: " . $con->error;}
$insert4 = "insert into Issue (issue_name, department_id) values ('Receiving Discrepancy',6)"; //Logistics
$run_insert4 = mysqli_query($con,$insert4);
if($run_insert4){echo "Receiving Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert5 = "insert into Issue (issue_name, department_id) values ('RMA Discrepancy',4)"; //Customer Service
$run_insert5 = mysqli_query($con,$insert5);
if($run_insert5){echo "RMA Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert6 = "insert into Issue (issue_name, department_id) values ('PO Discrepancy',6)"; //logistics
$run_insert6 = mysqli_query($con,$insert6);
if($run_insert6){echo "PO Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert8 = "insert into Issue (issue_name, department_id) values ('Listing Discrepancy',2)"; //operations
$run_insert8 = mysqli_query($con,$insert8);
if($run_insert8){echo "Listing Discrepancy inserted";}
else{echo "error: " . $con->error;
$insert9 = "insert into Issue (issue_name, department_id) values ('Manufacturing Discrepancy',1)"; //buyers
$run_insert9 = mysqli_query($con,$insert8);
if($run_insert9){echo "Manufacturing Discrepancy inserted";}
else{echo "error: " . $con->error;}
$insert1 = "insert into Department (Department_name) values ('Buyers')";
$run_insert1 = mysqli_query($con,$insert1);
$insert2 = "insert into Department (Department_name) values ('Operations')";
$run_insert1 = mysqli_query($con,$insert2);
$insert3 = "insert into Department (Department_name) values ('IT')";
$run_insert1 = mysqli_query($con,$insert3);
$insert4 = "insert into Department (Department_name) values ('Customer Service')";
$run_insert1 = mysqli_query($con,$insert4);
$insert5 = "insert into Department (Department_name) values ('HR')";
$run_insert1 = mysqli_query($con,$insert5);
$insert6 = "insert into Department (Department_name) values ('Logistics')";
$run_insert1 = mysqli_query($con,$insert6);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyers
$run_insert1 = mysqli_query($con,$insert1);
/*$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyers
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyers
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //IT
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //IT
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //logistics
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //operations
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyers
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //operations
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //HR
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //operation
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)";// IT
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyer
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)"; //buyer
$run_insert1 = mysqli_query($con,$insert1);
$insert1 = "insert into Employee (email, first, last, department_id) values ('email@email.com','First', 'Last',3)";
$run_insert1 = mysqli_query($con,$insert1);*/ // Customer Service
if (isset($_GET['id'])) {
$id = $_GET['id'];
echo $id .'<br>';
$sql = "UPDATE Ticket_Main SET complete = 1 WHERE id='$id'";
if ($con->query($sql) === TRUE) {
echo "Complete is updated successfully";
} else {
echo "Error updating record: " . $con->error;
}
$date1 = date("Y-m-d H:i:s");
$insert = "insert into TransAct (date_time) values ('$date1')";
$run_insert = mysqli_query($con,$insert);
}else{
$issue = $_POST['issue'];
$priority = $_POST['priority'];
$date = date("Y-m-d H:i:s");
$type1 = $_POST['type1'];
$author = $_POST['author'];
if($issue != null){
$sel = "select id from Issue Where issue_name='$type1'";
$run1 = mysqli_query($con,$sel);
$res = mysqli_fetch_array($run1, MYSQLI_NUM);
$run = $res[0];
$insert = "insert into Ticket_Main (request,date,priority,issue_id,author,complete) values ('$issue', '$date','$priority','$run','$author',0)";
$run_insert = mysqli_query($con,$insert);
$sel1 = "select id from Ticket_Main Where date='$date'";
$run2 = mysqli_query($con,$sel1);
$res1 = mysqli_fetch_array($run2, MYSQLI_NUM);
$MainId = $res1[0];
$sql = "UPDATE Ticket_Main SET complete = 1 WHERE id='$MainId'";
$sel2 = "select department_id from Issue Where issue_name = '$type1'";
$run3 = mysqli_query($con,$sel2);
$res2 = mysqli_fetch_array($run3, MYSQLI_NUM);
$DepId = $res2[0];
$sel3 = "select department_name from Department Where id='$DepId'";
$run4 = mysqli_query($con,$sel3);
$res3 = mysqli_fetch_array($run4, MYSQLI_NUM);
$Dep = $res3[0];
$insert1 = "insert into TransAct (Ticket_Main_id,iscomplete,request_sender,request_reciever) values ('$MainId',0,'$author','$Dep')";
$run_insert1 = mysqli_query($con,$insert1);
if($run_insert){}
else{echo "error: " . $con->error;}
$sel4 = "select email from Employee Where department_id = '$DepId'";
$run5 = mysqli_query($con,$sel4);
$res4 = mysqli_fetch_array($run5, MYSQLI_NUM);
$last = explode(' ', $author);
$lastn = $last[1];
$sel5 = "select email from Employee Where last = '$lastn'";
$run6 = mysqli_query($con,$sel5);
$res5 = mysqli_fetch_array($run6, MYSQLI_NUM);
$sender = $res5[0];
for($i = 0; $i<count($res4); $i = $i + 1){
$to = $res4[$i];
$subject = $priority .' ' . $type1 . ' Ticket #' . $MainId; //what is a good subject format?
$message = $issue .
"
Please click the following link to mark the ticket as resolved:
http://myhtml.com";
$from = "From: " . $author . " <'$sender'>";
//$from = "From: " . $author . " <" . $sender . ">";
mail($to,$subject,$message,$from);
}
}
}
mysqli_close($con);
?>