Global Variable send to SQL String

Dear gurus,

I have global variable created in orders application, called [globid].
Inside orders form, I created button “print” to print pdf invoice.
I used sc_redir(“print”,globid={no_order})

Inside the print application pdf, I created $sqlstr to get records from recordset with no_order

$sqlstr=‘select fnamabrg, fqty,fharga from orderdetails inner join goods on orderdetails.fkodebrg=goods.fkodebrg where fnojual=$globid’;

but i get error

select fnamabrg, fqty,fharga from orderdetails inner join goods on orderdetails.fkodebrg=goods.fkodebrg where fnojual=$globidTCPDF ERROR: Some data has already been output, can’t send PDF file

How i can use global variable globid to get records ?

Thank you

Regards

i got it worked, by using this

$sqlstr=“select fnamabrg, fqty,fharga from orderdetails inner join goods on orderdetails.fkodebrg=goods.fkodebrg where fnojual=’”. [globid] ."’";

but now, another error rise.

Fatal error: Uncaught Error: Call to undefined function sc_lookup()

Hi, paste the whole code…

I read from sources, and I realized I should not put the code inside TCPDF->code, So I put this inside onRecord events

$sqlstr=“select fnamabrg, fqty,fharga from tbjualdet inner join tbbarang on tbjualdet.fidbarang=tbbarang.fidbarang where fnojual=’”. [globjual] ."’";

sc_lookup(my_data, $sqlstr);

if (!empty ({my_data})) {
$datasetCount = count({my_data}); // returns count of array items of any array

for($j=0; $j < $datasetCount; $j++)
{
    [strbrg].={my_data}[$j][0];
    [strbrg].=".";
    $i++;

}
}
else
{
[strbrg]="";
}

And inside Layout PDF->code, i put this

$name_prod = [strbrg];
$arr_name_prod = explode(".",$name_prod);
foreach($arr_name_prod as $typeName){
$pdf->SetXY(5, $ContPosY);
$pdf->Write(0, $typeName, ‘’, 0, ‘L’, true, 0, false, false, 0);
$ContPosY+=4;
}

And voila, now my pdf able to show the details

hope,this able to help someone.

thank you