Maybe I did not explain it well.
The application is installed on a hosted server and the database is also on this server
1- I access from home and input data - everything is OK
2- One user tested the application before use and accessed from home. - everything is OK
3- Users who access the app from the business location, however, fail to make a mistake.
So in all three cases it is an identical database.
But not always. As if the error occurred randomly. What day is even all day OK, the second day there is an error.
The input scenario is as follows:
User enters 4 fields. Then the date field appears and in this field I have AjaxEvent to save the data:
sc_ajax_javascript (‘nm_atualiza’, array (“incluir”));
For this, there are two optional fields that are sometimes entered or not.
Then I have a php SAVE button to create all 18 forms with this code:
sc_commit_trans (); // save the changes (inserts the data)
izpolni_kpk_01 ();
izpolni_kpk_02 ();
izpolni_kpk_03 ();
izpolni_kpk_04 ();
izpolni_kpk_05 ();
izpolni_kpk_06 ();
izpolni_kpk_07 ();
izpolni_kpk_08 ();
izpolni_kpk_09 ();
izpolni_kpk_10 ();
izpolni_kpk_11 ();
izpolni_kpk_12 ();
izpolni_kpk_13 ();
izpolni_kpk_14 ();
izpolni_kpk_15 ();
izpolni_kpk_16 ();
izpolni_kpk_17 ();
izpolni_kpk_18 ();
sc_ajax_javascript (‘nm_atualiza’, array (“alterar”));
sc_redir (kpk_form_01.php, id = {id}, “_self”);
To switch to another page, I use a button with the following code:
$l_link = “…/kpk_form_02/kpk_form_02.php? id =”. {id};
{page_02} = “<a href=”.$l_link. "onclick = " nm_atualiza (‘alterar’); “> <img src = ‘…/_ lib/img/grp__NM__ico__NM__stran_02_green.png’/></a>”;
Although I do not know here exactly why I did this, I saved the data again, but if I sum up all the data I saved 3x.
Creation code. copying the data ( izpolni_kpk_04 (); ) into other tables is as follows:
/ * Complete the patient and his information on page 04 * /
$id_pacienta = {id_pacienta};
$datum_razgovora4 = {datum_razgovora};
/** * Check for an existing record */
// SQL statement parameters
$check_table = ‘kila_pot_04’; // Table name
$check_where = “id = ‘{id}’”; // Where clause
// Check for record
$check_sql = ‘SELECT *’
. ’ FROM ’ . $check_table
. ’ WHERE ’ . $check_where;
sc_select(dataset, $check_sql);
if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
// START No record found
/*** Insert a record on another table */
// SQL statement parameters
$insert_table = ‘kila_pot_04’; // Table name
$insert_fields = array( // Field list, add as many as needed
'id_pacienta' => "'$id_pacienta'",
'datum_razgovora4' => "'$datum_razgovora4'",
);
// Insert record
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
// END No record found
}
else
{
// START Record found
/*** Start Update a record on another table */
// SQL statement parameters
$update_table = ‘kila_pot_04’; // Table name
$update_where = “id = ‘{id}’”; // Where clause
$update_fields = array( // Field list, add as many as needed
// “id_pacienta = ‘$id_pacienta’”,
“datum_razgovora4 = ‘$datum_razgovora4’”,
);
// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);
/*** End Update a record on another table */
// END Record found
}
// ***********************************************************************************************************************************************************************************
I have set the id for all tables on auto_increment.
Could it be a better idea to have only a table_00 auto_increment, and all others would be set to Auto Increment (manual), but I’m not sure how it works at all.
Any idea or advice what am I doing wrong?