Run Button does not work with sc_lookup

Hello,

I write my code in the Events and set my arrays. In onFinish the code is:
for($x=0; $x < count([total_chked]) ; $x++){
echo $x."-";

$P_Key= [total_chked][$x];

$sql ="SELECT Flaschenversorgung, vertrag.Vertragsname FROM  vertrag_flaschen  INNER JOIN  vertrag  ON (vertrag_flaschen.vertrag_id = vertrag.vertrag_id) WHERE    (vertrag_flaschen.vertrag_flaschen_id = ".[total_chked][$x].")";


sc_lookup(dataset,     $sql );

} //for

My loop breaks when I call sc_lookup. When I comment out this part, then the loop works. But why I can not use the lookup?

So there must be an error in the $sql.

try some things: [LIST=1]

  • add a singel bracket in the id part of the where clause. Sometimes this is a solution ==> WHERE (vertrag_flaschen.vertrag_flaschen_id =[SIZE=20px]'[/SIZE]".[total_chked][$x]."[SIZE=24px]'[/SIZE])";
  • replace your [total_chked][$x] in the where clause by a value. So skip the array and see what happens.
  • do a print_r ([total_chked][$x]); to check if there is a value in the array [/LIST]
  • Hello Simon,

    I agree with nonkelmike.

    Best way to check this, usually is to turn on the debug mode in application > settings and see what the real SQL command is, which Scriptcase tries to execute. In most cases you’ll recognize what is wrong.

    Sincerely

    Gunter Eibl