Jump to content

Parse error: syntax error, unexpected '{', expecting ')'


Recommended Posts

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";

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]')";

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 ^_^

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

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.

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.

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.

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 ;)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.