Code: Select all
$query = "UPDATE building_maintenance_tickets SET maintenance_notes = '{$notes}' WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection); //Confirm that the query was performed
Moderator: General Moderators
Code: Select all
$query = "UPDATE building_maintenance_tickets SET maintenance_notes = '{$notes}' WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection); //Confirm that the query was performed
Code: Select all
$query = "UPDATE building_maintenance_tickets SET maintenance_notes = '{$notes}' WHERE id = " . $ticket_id;
die( $query );
$result = mysql_query($query, $connection); //Confirm that the query was performed
Code: Select all
$result = mysql_query($query, $connection) or die( mysql_error( $connection) ); //Confirm that the query was performedThe word that it was hitting was "don't".You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 't1 Updated by Living Faith staff 12,02,2008 13:49:33 ca
Code: Select all
<?php
if(isset($_POST['ticket_id'])){
$ticket_id = $_POST['ticket_id'];
mysql_real_escape_string($ticket_id);
}else{
echo "No ticket number was provided";
}
if(isset($_POST['status'])){
$tenant_status = $_POST['status'];
mysql_real_escape_string($tenant_status);
}else{
echo "No status was provided";
}
if(isset($_POST['description'])){
$tenant_description = $_POST['description'];
mysql_real_escape_string($tenant_description);
}else{
$tenant_description = "";
}
//IF THE TICKET STATUS US STILL LEFT TO OPEN
$date = date("m,d,Y");
$time = 10800 + time();
$time = date("H:i:s", $time);
if ($tenant_status == "open"){
//Getting the database info DATABASE
$query = "SELECT * FROM building_maintenance_tickets WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection); //Confirm that the query was performed
if ($result) {
$row = mysql_fetch_array($result);
$notes = $row['maintenance_notes'];
$company = $row['company'];
$coquery = "SELECT company FROM tenants WHERE id = " . $row['company']; //getting the company info from their ID
$result = mysql_query($coquery, $connection);
if ($result){
$row = mysql_fetch_array($result);
$companyname = $row['company'];
$notes .= " " . $tenant_description . " " ;
$notes .= "Updated by ";
$notes .= $row['company'];
$notes .= " on " . $date . " " . $time . " \r\n\r\n";
}else{
$notes = $tenant_description;
}
}
[b]mysql_real_escape_string($notes);
//UPDATE DATABASE<br>
$query = "UPDATE building_maintenance_tickets SET maintenance_notes = '{$notes}' WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection) or die( mysql_error( $connection) ); //Confirm that the query was performed[/b]
if ($result) {
//EMAIL LIVING FAITH STAFF THAT THE TICKET WAS NOT CLOSED
$select_query = "SELECT email_address from notification_emails WHERE work_duty LIKE '%building%'"; //select LFC building maintenance emails
$result = mysql_query($select_query, $connection);
if($result){
while ($emailrow = mysql_fetch_array($result)){
$Name = "Living Faith Church "; //senders name
$mainemail = "administration@lfmi.org"; //senders e-mail adress
$recipient = $emailrow['email_address']; //recipient
$mail_body = "Closure of Building Trouble Ticket #" . $ticket_id . " was denied. The following reason was provided: " . $tenant_description . ". \r\n\r\n Please click the link below to review the ticket.\r\n
http://www.lfmi.org/tenants/view_buildi ... php?ticid=" . $ticket_id;
$subject = "Building Maintenance Trouble ticket for " . $companyname; //subject
$header = "From: ". $Name . " <" . $mainemail . ">\r\n"; //optional headerfields
if (mail($recipient, $subject, $mail_body, $header)){//notify event coordinator that the checklist is coming
}else{
echo "Emails were not sent to Living faith. Please contact technical support at 703-331-3820";
}
}
}else{
echo "The query never worked! Contact Living Faith";
}
}else{
echo "There was a problem with the system. Please contact Living Faith IT.";
}
echo "<br /><span class = \"text\">Thank you. Living Faith has been notified that the ticket is still open.</span><br />";
}else{
//Getting the database info DATABASE
$query = "SELECT * FROM building_maintenance_tickets WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection); //Confirm that the query was performed
if ($result) {
$row = mysql_fetch_array($result);
$notes = $row['maintenance_notes'];
$company = $row['company'];
$coquery = "SELECT company FROM tenants WHERE id = " . $row['company']; //getting the company info from their ID
$result = mysql_query($coquery, $connection);
if ($result){
$row = mysql_fetch_array($result);
$companyname = $row['company'];
$notes .= "" . $tenant_description;
}else{
$notes = $tenant_description;
}
}
//UPDATE DATABASE - CLOSE ticket
$notes .= "This ticket was closed by " . $companyname . " on " . $date . " at " . $time . ".";
$query = "UPDATE building_maintenance_tickets SET status = 'closed', maintenance_notes = '$notes'
WHERE id = " . $ticket_id;
$result = mysql_query($query, $connection); //Confirm that the query was performed
if ($result) {
echo "<br /><br /><span class = \"text\">Thank you. The ticket has been closed.</span>";
}else{
echo "The ticket could not be closed. Please contact Living Faith IT.";
}
}
?>
Code: Select all
mysql_real_escape_string($notes);Code: Select all
$notes = mysql_real_escape_string($notes);