$cont_por_cli_sql = "SELECT id_contactos
FROM cli_contactos
WHERE id_cliente = ".$CLIENTE."";
sc_lookup(cpc,$cont_por_cli_sql);
$CONT = count({cpc});
$CONT2 = {cpc};
$PERMISO = {permiso};
$USUARIO = {id_usuario};
echo "$CONT";
echo "$CONT2";
echo "{cpc}";
foreach({cpc} as $contactos){
$insert_cli_sql = "INSERT INTO cli_permisos (id_usuario, id_contacto, permiso)
VALUES (".$USUARIO.", ".$contactos.", ".$PERMISO." )
ON DUPLICATE KEY UPDATE permiso = ".$PERMISO."";
sc_exec_sql($insert_cli_sql);
}
Array to string conversion
ADOConnection.Execute(INSERT INTO cli_permisos (id_usuario, id_contacto, permiso)
VALUES (9, Array, N )
I’m try whit while and for, but only insert the first row in the insert an the second $contactos it’s empty
$CONT = cont({cpc});
$i = 1;
while ($i <= $CONT){
$contactos = {cpc[0][$i]};
$insert_cli_sql = "INSERT INTO cli_permisos (id_usuario, id_contacto, permiso)
VALUES (".$USUARIO.", ".$contactos.", ".$PERMISO." )
ON DUPLICATE KEY UPDATE permiso = ".$PERMISO."";
sc_exec_sql($insert_cli_sql);
$i++;
}