Parse error: syntax error, unexpected T_STRING

Dear all,

I’m tryng to use this code to test age and sex of the user . Then with a series of if and elseif I calc some values.
At the level of first elseif I receive the error: Parse error: syntax error, unexpected T_STRING .
Is the sintax for using elseif correct ? I comment second part to understant where is the error.
if test { }
elseif test { }
elseif test { }

else { }

Anybody can help me ? Thanks . Giovannino

$sql =“SELECT SUM(quantity)as somma_qta FROM dayly_in WHERE dayly_in.id_dayly_in_m = {id_dayly_in_m} AND dayly_in.date_in = ‘{date_in}’”;

sc_lookup(dataset,$sql);
$somma_qta_r = {dataset[0][0]};

$sql_years = sc_exec_sql(“SELECT distinct years_old FROM users WHERE user_name = ‘[v_resource]’”);
$sql_sex = sc_exec_sql(“SELECT distinct sex FROM users WHERE user_name = ‘[v_resource]’”);

echo “Age”.$sql_years ;
echo “Sex”.$sql_sex ;

// Et? fino a 8 target 1400 M e F
if ($sql_years < =8)
{
$somma_qta1 = 1400 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
}
elseif ($sql_years between 9 and 14) and ($sql_sex = 1)
{
$somma_qta1 = 2300 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);

}
/*

elseif ($sql_years between 9 and 14) and ($sql_sex = 2)
{
$somma_qta1 = 2100 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
}

// Et? > 14 target 3200 M e 2500 F
}else if (sc_exec_sql(“SELECT distinct years_old FROM users WHERE user_name = ‘[v_resource]’”)> 14 and
sc_exec_sql(“SELECT distinct sex FROM users WHERE user_name = ‘[v_resource]’”) = 1)
{
$somma_qta1 = 3200 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
}else (sc_exec_sql(“SELECT distinct years_old FROM users WHERE user_name = ‘[v_resource]’”)> 14 and
sc_exec_sql(“SELECT distinct sex FROM users WHERE user_name = ‘[v_resource]’”) = 2)
{
$somma_qta1 = 3200 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
}
}
*/

Re: Parse error: syntax error, unexpected T_STRING

It is hard to debug this since it is using all SC macros. At first glance it looks fine, but there still may be a problem with the syntax of an SC call.
Have you tried opening up the generated file and look for your code and see if the macro calls in your code are generating proper PHP code? The error seems to not like a quote mark.

Here is a quick site for testing PHP code (will not work for SC macro calls, not SQL, just PHP)
http://writecodeonline.com/php/

They also have a dropdown for JS code as well.

Regards,
Scott.

Re: Parse error: syntax error, unexpected T_STRING

Thanks Scott as always !
I’ve modified the scripts (after many&many test…) and it seems work better now.

between does not work (? why) --> else if ($sql_years between 9 and 14 and $sql_sex = 1)

in this way it works —> else if ($sql_years >= 9 and $sql_years <= 14 and $sql_sex = 1)

Just to know there are some reasons about above (?)

Reviewed code:

$sql =“SELECT SUM(quantity)as somma_qta FROM dayly_in WHERE dayly_in.id_dayly_in_m = {id_dayly_in_m} AND dayly_in.date_in = ‘{date_in}’”;
sc_lookup(dataset,$sql);
$somma_qta_r = {dataset[0][0]};

$sql_years0 = sc_exec_sql(“SELECT years_old, sex FROM users WHERE user_name = ‘[v_resource]’”);
sc_lookup(dataset_y,$sql_years0);
$sql_years = {dataset_y[0][0]};
$sql_sex = {dataset_y[0][1]};

// Et? fino a 8 target 1400 M e F
if ($sql_years <= ‘8’)
{
echo " fino a 9 ";
$somma_qta1 = 1400 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
// Et? da 9 a 14 target 2300 M e 2100 F
}
else if ($sql_years >= 9 and $sql_years <= 14 and $sql_sex = 1)
{
echo " da 9 a 14 ";
$somma_qta1 = 2300 - $somma_qta_r ;
sc_master_value(‘day_lacking’, $somma_qta1);
sc_format_num({day_lacking}, ‘.’, ‘’, 0, ‘N’, ‘1’, ‘’);
}