A
|
acpan 9/4/2021 |
Not sure what you are trying to say, but i see your DB Query syntax mixing and there is some error in it and likely no relation with timing of session value. Some errors in your statement:
Also make sure both your queries return only 1 record (use ORDER BY and LIMIT 0,1), else it may give you unpredictable result. You can try to use this: // To get masterkey (workorder) in session |
A
|
Abul author 9/4/2021 |
Thank you so much acpan for taking time in helping me. However, the code you gave me did not work. Rather now the "labid' field on sample add page left blank for all entry. It looks like at the begining of the entry the $master_key = $_SESSION["sample_masterkey1"] value can not be captured as I have checked on my database query. Because sample table has not yet records. I will appreciate your continuous helping please. |
A
|
acpan 9/4/2021 |
Is above correct? Can you show where is the first $_SESSION["sample_masterkey1" ] you put, show how and where you assign or get the session var.
|
A
|
Abul author 9/4/2021 |
Hi acpan, Thank you so much for your quick respond. By this time I have done so many tricks on my db. And finally it seems working for me. I found that my sql query in earlier code was not able to pull Clientno and sampletype based on workordid when sample table remain totally empty. This was because my earlier query included sample table. $data = $_SESSION["sample_masterkey1"]; //get masterkey in session |
A
|
acpan 9/4/2021 |
i see that you revert back to the old style. if it works for you, then it is ok. Good luck! |
A
|
acpan 9/4/2021 |
Not sure why you revert to using db_fetch_array($rs) instead of my recommendation while( $data = $rs->fetchAssoc() ) . This is one of the 3 points i asked you to correct. db_fetch_array($rs) is already deprecated |
A
|
Abul author 9/4/2021 |
Hi acpan, here is your code I used: $data = $_SESSION["sample_masterkey1"]; //get masterkey in session and I got this wrong result with target field "LabID" left blank.
However, I dont get any error but got the right result as per my goal with my revised code as mentioned in my last reply above. Please see the screen shot below.
|
A
|
acpan 9/5/2021 |
This is clearer with picture.
My version test the first query, and if empty, exit immediately; -- this is what you want.
With this omitted, the final part WILL NOT be executed, this is why you see LabID is empty.
$data is used as ARRAY in many places. You should avoid naming your variable as $data, to prevent overwrite of PHPRunner's arrays in some events codes if you are not careful, as a good practice. |
A
|
acpan 9/5/2021 |
It is better to assign $str this way to prevent ambiguity, change this: $str=0; === Change to ==> $str=""; and if ($str != 0 ) === change to ==> if ($str != "" ) |
A
|
Abul author 9/5/2021 |
Hi acpan, I have revised my code as per your suggession and yes now it is working as per my goal. Thank you so much. Here is my final revised code and the result screen shot. $master_key = $_SESSION["sample_masterkey1"];
|
A
|
acpan 9/5/2021 |
Ok, great! I removed this since it is not necessary anymore. |
A
|
acpan 9/5/2021 |
Okay, it works now for you as above, happy coding! |
A
|
Abul author 9/5/2021 |
Hi acpan, |
A
|
acpan 9/5/2021 |
Just a disclaimer: I am randomly assisting on debugging that caught my interest at the right time, whenever i am free to drop by. For urgent or more complicated cases, especially cases where you think you might need hand-holding, Xlinesoft's professional service team is definitely a go-to contact for such dedicated support and in-depth debugging :) happy coding! |