saragoth Posted March 30, 2010 Share Posted March 30, 2010 Guys getting this error using this piece of code.. This was working (kind of) until I moved it from php 4 to 5.. Any thoughts would be appreciated. I am still very new at this so if it's something bone headedly obvious, please be gentle <?php $con = mysql_connect("localhost","xxx","xxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("facility", $con); ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; $t = 'fac_trans_switch_dca'; $fac_trans_switch_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_ups_dca'; $fac_ups_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_server_alarms_dca'; $fac_server_alarms_dca = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_ac_leaks_dca'; $fac_ac_leaks_dca = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_trash_dca'; $fac_trash_dca = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_kitchen_dca'; $fac_kitchen_dca = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_doors_dca'; $fac_doors_dca = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_trash_dcb'; $fac_trash_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_lostitems_dcb'; $fac_lostitems_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_cables_dcb'; $fac_cables_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_leaks_dcb'; $fac_leaks_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_equipment_dcb'; $fac_equipment_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_console_dcb'; $fac_console_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_server_alarms_dcb'; $fac_server_alarms_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_ac_leaks_dcb'; $fac_ac_leaks_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_rear_door_dcb'; $fac_rear_door_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_rear_alarm_dcb'; $fac_rear_alarm_dcb = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $sql="INSERT INTO facility (fac_date_month, fac_date_day, fac_date_year, fac_tech_name, fac_time, fac_trans_switch_dca, fac_ups_dca, fac_server_alarms_dca, fac_ac_leaks_dca, fac_trash_dca, fac_kitchen_dca, fac_doors_dca, fac_trash_dcb, fac_lostitems_dcb, fac_cables_dcb, fac_leaks_dcb, fac_equipment_dcb, fac_console_dcb, fac_server_alarms_dcb, fac_ac_leaks_dcb, fac_rear_door_dcb, fac_rear_alarm_dcb) VALUES ( {$fac_date_month}, {$fac_date_day}, {$fac_date_year}, {$fac_tech_name}, {$fac_time}, {$fac_trans_switch_dca}, {$fac_ups_dca}, {$fac_server_alarms_dca}, {$fac_ac_leaks_dca}, {$fac_trash_dca}, {$fac_kitchen_dca}, {$fac_doors_dca}, {$fac_trash_dcb}, {$fac_lostitems_dcb}, {$fac_cables_dcb}, {$fac_leaks_dcb}, {$fac_equipment_dcb}, {$fac_console_dcb}, {$fac_server_alarms_dcb}, {$fac_ac_leaks_dcb}, {$fac_rear_door_dcb}, {$fac_rear_alarm_dcb} )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/ Share on other sites More sharing options...
aeroswat Posted March 30, 2010 Share Posted March 30, 2010 What is this supposed to do? ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1034329 Share on other sites More sharing options...
Jax2 Posted March 30, 2010 Share Posted March 30, 2010 Why are you using: VALUES ( {$fac_date_month}, {$fac_date_day}, {$fac_date_year}, etc)"; Should be: value ('$fac_date_month', '$fac_date_day', '$fac_date_year', ...); at least as far as I know ... What line is the error on? Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1034337 Share on other sites More sharing options...
aeroswat Posted March 30, 2010 Share Posted March 30, 2010 Why are you using: VALUES ( {$fac_date_month}, {$fac_date_day}, {$fac_date_year}, etc)"; Should be: value ('$fac_date_month', '$fac_date_day', '$fac_date_year', ...); at least as far as I know ... What line is the error on? this too Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1034356 Share on other sites More sharing options...
saragoth Posted March 31, 2010 Author Share Posted March 31, 2010 What is this supposed to do? ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; These are for options that don't require a true/false.. they are drop down menus in the html.. I'm basically just learning from books and the internet.. I'm in no way an expert.. Error is on line 10 Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1034711 Share on other sites More sharing options...
aeroswat Posted March 31, 2010 Share Posted March 31, 2010 What is this supposed to do? ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; These are for options that don't require a true/false.. they are drop down menus in the html.. I'm basically just learning from books and the internet.. I'm in no way an expert.. Error is on line 10 Options for what? I still don't understand... That's your error. They aren't doing anything. All you have is a bunch of POST variables wrapped in parentheses and separated by commas. Also at the end of those parentheses there is a double quote that doesn't seem to be a part of anything. Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1034798 Share on other sites More sharing options...
TeddyKiller Posted April 1, 2010 Share Posted April 1, 2010 Am I the only one seeing the problem? ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; Theres an open double quote at the end. This makes no sense either, but this will be causing a problem. Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1035028 Share on other sites More sharing options...
mikesta707 Posted April 1, 2010 Share Posted April 1, 2010 those double quotes are what is causing the problem, but OP's code is still unclear at best, and completely arbitrary and useless at worse. What exactly are you trying to do? because whatever it is, I don't think that code will do it. Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1035035 Share on other sites More sharing options...
aeroswat Posted April 5, 2010 Share Posted April 5, 2010 Am I the only one seeing the problem? ('$_POST[fac_date_month]', '$_POST[fac_date_day]', '$_POST[fac_date_year]', '$_POST[fac_tech_name]', '$_POST[fac_time]', '$_POST[fac_ups1_kva_out]', '$_POST[fac_ups1_phasebkw_out]', '$_POST[fac_ups1_battery_time]', '$_POST[fac_ups2_kva_out]', '$_POST[fac_ups2_phasebkw_out]', '$_POST[fac_ups2_battery_time]', '$_POST[fac_notes]')"; Theres an open double quote at the end. This makes no sense either, but this will be causing a problem. Or possibly the only one not reading considering i posted it several times before those double quotes are what is causing the problem, but OP's code is still unclear at best, and completely arbitrary and useless at worse. What exactly are you trying to do? because whatever it is, I don't think that code will do it. Someone caught on Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1037285 Share on other sites More sharing options...
TeddyKiller Posted April 5, 2010 Share Posted April 5, 2010 Oh damn. I didn't actually read your post properly. >.< Quote Link to comment https://forums.phpfreaks.com/topic/197029-parse-error-syntax-error-unexpected-expecting/#findComment-1037405 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.