sc_exec_sql - not working ?!?!

I’m trying to update one table with data from another.
I want to get a default checklist depending on the type of check.
I thought (I know) that I could use sc_exec_sql macro to do this but I’m getting the following message no matter what!

The sql (Which works nicely when executed in Mysql) I want to execute is:

SET foreign_key_checks = 0;
INSERT INTO proj_rev_checklist (proj_rev_def_list_proj_rev_def_list_id, proj_proj_id)
SELECT proj_rev_def_list_proj_rev_def_list_id, 1
FROM proj_rev_def_list_has_proj_rev_type WHERE proj_rev_type_proj_rev_type_id = 1;
SET foreign_key_checks = 1;

Now I have deleted everything and I only have the below in my form under events ‘OnScriptInit’ …

$sqlstring1 = “”;

$sqlstring2 = “”;

$sqlstring3 = “”;

/*

  • This macro execute SQL commands passed as parameter or a SQL command in the SQL field action type.
    */
    sc_exec_sql("$sqlstring1")
    sc_exec_sql("$sqlstring2")
    sc_exec_sql("$sqlstring3")


It returns the following error:
Parse error: syntax error, unexpected ‘;’ in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\beta\form_projects\form_projects_apl.php on line 2335

I need to make sure this is not a bug and if not could someone please give me a direction on what could be the issue :slight_smile:

Thanks …

I’ve tried it with and without semicolon at the end of the SQL.

Check the mentioned generated line BEFORE… So on line 2335. You can do that by using view_source. You will see that the line contains en error there…

C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\beta\form _projects\form_projects_apl.php on line 2335

Solution found (might be a workaround) anyway mission accomplished.

I’ve moved the sc_exec_sql statement to the ‘programming’ -> ‘PHP Methods’, and then I call the function from the event.

… and now it’s working :-))

If the code you posted is the code on your event, then you are missing the semicolons after sc_exec_sql() to end the line.