ptrane55 Posted September 8, 2009 Share Posted September 8, 2009 Hello, I am a newbie to programming in general. My script is connecting to the database and the only data posting is the datetime fields. I am using an MSSQL database. Here is query: <php> <?php //connect to a DSN "myDSN" $conn = mssql_connect('srvessesql2','nmi','nmi'); $db = mssql_select_db("Essebase"); if ( !$conn) { throw new Exception ('Could not connect' . print_r(sqlsrv_errors(), true)); } else { echo "Connection Successful <br />"; } //near_miss_incident colums and input names //$incident_id = addslashes($_POST['$row']); $date_of_incident = addslashes($_POST['date_of_incident']); $date_incident_recorded = addslashes($_POST['date_incident_recorded']); $initial_incident_id = addslashes($_POST['initial_incident_id']); $last_name = addslashes($_POST['last_name']); $first_name = addslashes($_POST['first_name']); $middle_init = addslashes($_POST['middle_init']); $home_address = addslashes($_POST['home_address']); $home_phone = addslashes($_POST['home_phone']); $dob = addslashes($_POST['dob']); $gender = addslashes($_POST['gender']); $incident_individual_type = addslashes($_POST['incident_individual_type']); $mrn = addslashes($_POST['mrn']); $incident_location1 = addslashes($_POST['incident_location']); $incident_location2 = addslashes($_POST['incident_location2']); $incident_desc = addslashes($_POST['incident_desc']); $job_desc = addslashes($_POST['job_desc']); $safety_eq_utilized_yn = addslashes($_POST['safety_eq_utilized_yn']); $onsite_treatment_yn = addslashes($_POST['onsite_treatment_yn']); $require_treatment_yn = addslashes($_POST['require_treatment_yn']); $treatment_declined_reason = addslashes($_POST['treatment_declined_reason']); $treatment_location = addslashes($_POST['treatment_location']); $diagnosis_desc = addslashes($_POST['diagnosis_desc']); $treatment_desc = addslashes($_POST['treatment_desc']); $disposition_desc = addslashes($_POST['disposition_desc']); $incident_followup_yn = addslashes($_POST['incident_followup_yn']); $incident_followup_desc = addslashes($_POST['incident_followup_desc']); $injury_desc1 = addslashes($_POST['injury_desc']); $injury_desc2 = addslashes($_POST['injury_desc2']); $exposed_fluids_yn = addslashes($_POST['exposed_fluids_yn']); $exposed_fluids1 = addslashes($_POST['exposed_fluids']); $exposed_fluids2 = addslashes($_POST['exposed_fluids2']); $exposed_fluids_source = addslashes($_POST['exposed_fluids_source']); $exposed_chemicals = addslashes($_POST['exposed_chemicals']); $safety_devices1 = addslashes($_POST['safety_devices']); $safety_devices2 = addslashes($_POST['safety_devices2']); $unutilized_safety_reason = addslashes($_POST['unutilized_safety_reason']); $injury_exposed_bodypart = addslashes($_POST['injury_exposed_bodypart']); $injury_exposed_time = addslashes($_POST['injury_exposed_time']); $injury_exposed_treatment1 = addslashes($_POST['injury_exposed_treatment1']); $injury_exposed_treatment2 = addslashes($_POST['injury_exposed_treatment2']); $injury_injected_yn = addslashes($_POST['injury_injected_yn']); $injury_injected_amt = addslashes($_POST['injury_injected_amt']); $injury_bleed_yn = addslashes($_POST['injury_bleed_yn']); $hepb_shot_yn = addslashes($_POST['hepb_shot_yn']); $tetanus_shot_yn = addslashes($_POST['tetanus_shot_yn']); $cause_of_accident1 = addslashes($_POST['cause_of_accident']); $cause_of_accident2 = addslashes($_POST['cause_of_accident2']); $treating_phys_name = addslashes($_POST['treating_phys_name']); $treating_phys_id = addslashes($_POST['treating_phys_id']); $patient_complaint1 = addslashes($_POST['patient_complaint']); $patient_complaint2 = addslashes($_POST['patient_complaint2']); $procedure_desc1 = addslashes($_POST['procedure_desc']); $procedure_desc2 = addslashes($_POST['procedure_desc2']); $med_errors_desc = addslashes($_POST['med_errors_desc']); $equip_errors_desc = addslashes($_POST['equip_errors_desc']); $misc_desc = addslashes($_POST['misc_desc']); $preparer_name = addslashes($_POST['preparer_name']); $preparer_location = addslashes($_POST['preparer_location']); //the SQL statement that will query the database and insert data to near_miss_incident $query = "INSERT INTO near_miss_incident(DATE_OF_INCIDENT,DATE_INCIDENT_RECORDED,LAST_NAME,FIRST_NAME,MIDDLE_INIT,HOME_ADDRESS,HOME_PHONE,DOB,GENDER,INCIDENT_INDIVIDUAL_TYPE,MRN,INCIDENT_LOCATION,INCIDENT_DESC,JOB_DESC,SAFETY_EQ_UTILIZED_YN,ONSITE_TREATMENT_YN,REQUIRE_TREATMENT_YN,TREATMENT_DECLINED_REASON,TREATMENT_LOCATION,DIAGNOSIS_DESC,TREATMENT_DESC,DISPOSITION_DESC,INCIDENT_FOLLOWUP_YN,INCIDENT_FOLLOWUP_DESC,INJURY_DESC,EXPOSED_FLUIDS_YN,EXPOSED_FLUIDS,EXPOSED_FLUIDS_SOURCE,EXPOSED_CHEMICALS,SAFETY_DEVICES,UNUTILIZED_SAFETY_REASON,INJURY_EXPOSED_BODYPART,INJURY_EXPOSED_TIME,INJURY_EXPOSED_TREATMENT,INJURY_INJECTED_YN,INJURY_INJECTED_AMT,INJURY_BLEED_YN,HEPB_SHOT_YN,TETANUS_SHOT_YN,CAUSE_OF_ACCIDENT,TREATING_PHYS_NAME,TREATING_PHYS_ID,PATIENT_COMPLAINT,PROCEDURE_DESC,MED_ERRORS_DESC,EQUIP_ERRORS_DESC,MISC_DESC,PREPARER_NAME,PREPARER_LOCATION,OTHER_EMP_KNOWLEDGE) VALUES('".$DATE_OF_INCIDENT."','".$DATE_INCIDENT_RECORDED."','".$LAST_NAME."','".$FIRST_NAME."','".$MIDDLE_INIT."','".$HOME_ADDRESS."','".$HOME_PHONE."','".$DOB."','".$GENDER."','".$INCIDENT_INDIVIDUAL_TYPE."','".$MRN."','".$INCIDENT_LOCATION1."','".$INCIDENT_DESC."','".$JOB_DESC."','".$SAFETY_EQ_UTILIZED_YN."','".$ONSITE_TREATMENT_YN."','".$REQUIRE_TREATMENT_YN."','".$TREATMENT_DECLINED_REASON."','".$TREATMENT_LOCATION."','".$DIAGNOSIS_DESC."','".$TREATMENT_DESC."','".$DISPOSITION_DESC."','".$INCIDENT_FOLLOWUP_YN."','".$INCIDENT_FOLLOWUP_DESC."','".$INJURY_DESC1."','".$EXPOSED_FLUIDS_YN."','".$EXPOSED_FLUIDS1."','".$EXPOSED_FLUIDS_SOURCE."','".$EXPOSED_CHEMICALS."','".$SAFETY_DEVICES1."','".$UNUTILIZED_SAFETY_REASON."','".$INJURY_EXPOSED_BODYPART."','".$INJURY_EXPOSED_TIME."','".$INJURY_EXPOSED_TREATMENT."','".$INJURY_INJECTED_YN."','".$INJURY_INJECTED_AMT."','".$INJURY_BLEED_YN."','".$HEPB_SHOT_YN."','".$TETANUS_SHOT_YN."','".$CAUSE_OF_ACCIDENT1."','".$TREATING_PHYS_NAME."','".$TREATING_PHYS_ID."','".$PATIENT_COMPLAINT1."','".$PROCEDURE_DESC1."','".$MED_ERRORS_DESC."','".$EQUIP_ERRORS_DESC."','".$MISC_DESC."','".$PREPARER_NAME."','".$PREPARER_LOCATION."','".$OTHER_EMP_KNOWLEDGE."')"; $result = mssql_query($query) or trigger_error(print_r(sqlsrv_errors(), true).('Error inserting data.<br />')); ?> </php> Any Help would be great. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/173601-data-inserting-blank-records/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 8, 2009 Share Posted September 8, 2009 Variable names are case sensitive. $date_of_incident is not the same as $DATE_OF_INCIDENT Please develop php code and debug php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you. There would have been error messages concerning non-existent variables due to the mismatched names. Stop and start your web server to get any change made to php.ini to take effect and confirm that those settings actually got changed using a phpinof(); statement. Link to comment https://forums.phpfreaks.com/topic/173601-data-inserting-blank-records/#findComment-915089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.