Hi, I'm trying to insert a data to a table. some of the field that i want to insert are come from that table. so i create a temporary variable to define the data, then call the variable in the query. when i try to execute from sqlyog it's fine but when i try to execute it using php i get an error message
Quote:
ERROR You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT @lvl := level+1 from eslii_logicalframework where id_framework='5'; ' at line 2
my php code
$sq_insert="SELECT @kdfrm := CONCAT(kode_framework,'.".$nomor_urut."') from eslii_logicalframework where id_framework='".$lookup_id."';
SELECT @lvl := level+1 from eslii_logicalframework where id_framework='".$lookup_id."';
insert into eslii_logicalframework
(
kode_framework,
no,
level,
id_jenis,
logical_framework,
indikator_framework,
unitkey
)values
(
@kdfrm,
'".$nomor_urut."',
@lvl,
'".$data_post_select."',
'".$data_post."',
'".$data_post_ind."',
'".$unitkey_login."'
);";
if (!$result = mysqli_query($conmysql,$sq_insert)) {
echo"<div class='alert alert-mini alert-danger margin-bottom-30'> ERROR ".mysqli_error($conmysql)."</div>";
}
What I have tried:
i only try to execute the php code