$resp = json_decode($resp_json, true); if ($resp['status'] == 'OK') { $lat = round($resp['results'][0]['geometry']['location']['lat'], 6); $lon = round($resp['results'][0]['geometry']['location']['lng'], 6); } else { $error .= "-Unable to validate address."; } if ($error != '') { $error = "<strong>Error: Following fields are required</strong><br/>" . $error; echo json_encode(array("Error" => $error)); } else { $tblAddress['Company_Id'] = $_POST['Company_Id']; $tblAddress['Address_Lat'] = $lat; $tblAddress['Address_Lon'] = $lon; $ClassMaster->insert('tblAddress', $tblAddress); $Address_Id = $ClassMaster->LastID(); $tblClass['Company_Id'] = $_POST['Company_Id']; $tblClass['Address_Id'] = $Address_Id; if ($new_filename != '') { $new_filename = "http://ClassCrashers.wheresthepen.com/uploads/" . $new_filename; $tblClass['Class_Photo'] = $new_filename; } $tblClass['Class_Time'] = $_POST['txtOpenTimeHr'] . ":" . $_POST['txtOpenTimeMn'] . " " . $_POST['txtOpenTimeAMPM'] . " - " . $_POST['txtCloseTimeHr'] . ":" . $_POST['txtCloseTimeMn'] . " " . $_POST['txtCloseTimeAMPM']; if ($_POST['class_id'] == '') { $ClassMaster->insert('tblClass', $tblClass); $Class_Id = $ClassMaster->LastID(); } else { $Class_Id = mysqli_real_escape_string($ClassMaster->link(), $_POST['class_id']); $ClassMaster->update('tblClass', $tblClass, "Class_Id = '" . $Class_Id . "'"); } $ClassMaster->query("DELETE FROM tblInstructorClassXref WHERE Class_Id = '" . $Class_Id . "'");