problem with global var in server

i have a grid and a link to a form, access by control and pass user_id as a global var
the form has a global var defined on insert and update in field “user”

locally my project runs fine, but when upload and run in server the form does not update and give me an error in query:
"ERROR: syntax error at or near “[” … Update … user=[user_id] … "

Before error the grid works fine but after error the grid also gives the same error “ERROR: syntax error at or near “[” … Select coun(*)… where … user=[user_id] …”

All other forms and grids works fine with the same var. only this form and this grid and only in server, locally works fine and no errors.
Whats the problem ??

Thanks a lot

Re: problem with global var in server

is it a PHP error?? if so, it should say which line it occurred on, check that line and see where the error is. Copy and paste what the error says, if it gives a line number, copy and paste the line also.

Re: problem with global var in server

This is the error in grid.
error in form is similar but in update

these are the real variables, i try to simplify in the first post

I check in php code, but i dont see any grong.

in form the problem is “est_mod_user” field
the code:

$_SESSION[‘usu_id’] = $this->usu_id;

…{$this->est_mod_user = “” . $_SESSION[‘usu_id’] . “”;}…

why appear the value “[usu_id]” in the query if Scriptcase should change the value of “$_SESSION[‘usu_id’]” ???
anyway the value of $this->est_mod_user (in form) or $this->est_id_coord (in grid) should be the value of $this->usu_id
and the value of $this->usu_id is [usu_id]=rs[0][1] in my control form

I hope having explained

Re: problem with global var in server

Not 100% sure, but it sounds like a typo. Is that SQL select statement something you wrote, or something scriptcase wrote??? I don’t feel like counting characters, and I can’t select the error because it’s an image. It could also be that you want the est_mod_user field and for some reason it’s usu_id. Make sure the database tables are the same on your server and on your local machine. Let us know if that’s the problem or not, because if it works on your local machine and everything is the same online, it should work. Also, is usu_id just a global or a field in the table??? Lastly, where does usu_id get set and have you made sure with maybe an echo or alert statement, that the global is being passed through fine and has the correct value??

Re: problem with global var in server

The global pass ok, because i use in other forms and grids. Other globals vars also works well.
After log in the grid works ok, then load the form and when i click on update button get the error message, after that the grid stops working.

The DataBase is the same in local and server. i dont have access to server configuration.

I think Scriptcase doesn’t has writen some code correctly. I’ll try to change some things or remake the form.

Re: problem with global var in server

another thing is, do all your other forms work fine online??? have you put up the prod files in the correct place???

Re: problem with global var in server

So when you click on “update” button you get the error?

A select statement should not be executed when yuou do an update. Or is this a query you wrote yourself in one of the events? if so, apparently you can’t use globals there.

Re: problem with global var in server

he hasnt answered but i really think it’s a typo in his code. when i asked him to copy+paste the code here, he didnt. we can’t help if we don’t have the code to look at.

Re: problem with global var in server

ok. this is my project

Control: ctrl_access
Tab: coord_ctrl
Form: form_confirmar
Grid: coord_prel_lim
Menu: menu_ca

ctrl_access
Events: onValidate: sc_lookup(rec_set,“Select count(*), usu_id, usu_nombre, usu_paterno, usu_tipo, usu_nivel from usuario where usu_login=’{user}’ and usu_passwd=’{passwd}’ GROUP BY usu_id, usu_nombre, usu_paterno, usu_tipo, usu_nivel”);
if({rec_set[0][0]}<=0)
{
sc_error_message(“Usuario o Contrase?a incorrectos.”);
}else{

[usu_id]={rec_set[0][1]};
[usu_nombre]={rec_set[0][2]};
[usu_paterno]={rec_set[0][3]};
[usu_tipo]={rec_set[0][4]};
[usu_nivel]={rec_set[0][5]};
sc_redir(menu_ca,usu_id=[usu_id]; usu_nombre=[usu_nombre]; usu_paterno=[usu_paterno]; usu_tipo=[usu_tipo]; usu_nivel=[usu_nivel]:wink:

form_confirmar
atribute values: on update: est_mod_user: [usu_id]
events: onAfterUpdate: sc_redir(coord_ctrl);

coord_prel_lim
SQL:
SELECT e.est_id, i.inv_id, s.sol_id, i.inv_nombre, i.inv_paterno, i.inv_materno, e.est_responsable, e.est_fech_sol, e.est_fech_prel_lim, a.emp_codigo, d.tipo_inst
FROM
public.investigado i, public.estudio e, public.solicitud s, public.empresa a, public.tipo_instrumento d
WHERE
e.est_confirmada=‘1’ and s.sol_inv_id=i.inv_id and e.est_sol_id=s.sol_id and d.tipo_id=e.est_tipo_id and a.emp_id=i.inv_emp_id and e.est_id_coord=[usu_id] and e.est_fech_prel IS NULL and e.est_sts_id<>10 and e.est_sts2_id<>13

Events: onRecord: … sc_lookup(exist, “SELECT count(*) FROM atrasos WHERE atr_usu_id=[usu_id] and atr_sol_id={s.sol_id}”); …

Link: Aplication . form_confirmar (parameters: usu_id - var usu_id)

the process:

1.- Access the system by ctrl_access, redirect to menu_ca
2.- menu_ca execute coord_ctrl
3.- coord_ctrl execute coord_prel_lim (Global variable: attribute:usu_id ; scope: SESSION ; Type: in ; defined in: SQL command,
PHP formula (onLoadRecord) ) and works fine
4.- click to edit row with aplication link (form_confirmar)
5.- open form_confirmar with data
6.- click update button (give me an error on update but i can see wich one, only appear some times, only appear “procesing” leyend on top of page and don’t execute the redir function)
7.- when return to coord_ctrl tab the grid doesn’t work, give me this error:
Error al acceder el banco de datos
ERROR: syntax error at or near “[” at character 279
select count(*) from public.investigado i, public.estudio e, public.solicitud s, public.empresa a, public.tipo_instrumento d where e.est_confirmada=‘1’ and s.sol_inv_id=i.inv_id and e.est_sol_id=s.sol_id and d.tipo_id=e.est_tipo_id and a.emp_id=i.inv_emp_id and e.est_id_coord=[usu_id] and e.est_fech_prel IS NULL and e.est_sts_id<>10 and e.est_sts2_id<>13

if delete this part:
form_confirmar
atribute values: on update: est_mod_user: [usu_id]
events: onUpdate: sc_redir(coord_ctrl);

form_confirmar works fine in step 6
but grid give me the same error

the grid error only occurs when return of form_confirm

I have other form:
form_estudio
atribute values: on insert: est_ingr_user: [usu_id]
events: onAfterInsert: sc_redir(coord_ctrl);

and works fine. after insert the grid works fine to. BUT in this form [usu_id] don’t appear in Aplication- Global Variable

the project works in local machine, no errors (win 7, wamp server(apache 2.2.11, php 5.2.5) , postgres)
but in server doesn’t work (linux, apache 1.3.41, php 5.2.9, postgres)

in coord_prel_lim.php line 542:
if (!isset($_SESSION[‘usu_id’]))
{
$this->nm_falta_var .= "usu_id; ";
}

i added:
else{echo "exists session var: ".$_SESSION[‘usu_id’];}

on load the var have numeric data (id of my table) but after error var have “[usu_id]” as text.

I hope having explained
Thanks a lot!

Re: problem with global var in server

Where it says “WHERE
e.est_confirmada=‘1’ and s.sol_inv_id=i.inv_id and e.est_sol_id=s.sol_id and d.tipo_id=e.est_tipo_id and a.emp_id=i.inv_emp_id and e.est_id_coord=[usu_id] and e.est_fech_prel IS NULL and e.est_sts_id<>10 and e.est_sts2_id<>13” in your last select statement, it looks like your missing some ’ ', see if putting them in helps.

Re: problem with global var in server

yeah, works!

i confused, in other grids when put the global in statement without ’ ’ give me an error with data type char=integer
in this case the error was because the var have “[usu_id]” as text
Why work on load if the problem was the ’ ’ ??

The problem with Form persists :s

Thanks
jejeje that’s embarrasing :blush:

Re: problem with global var in server

so did it work or are you still having problems??

Re: problem with global var in server

sorry!
All works fine!
Thks ! :smiley: