How can I use PHP string var inside another one?

  fatal-error, informix, php

I’m trying to run a query; to make the string that has the query, I need to concatenate $org and $calendar . I have tried this:

$cal = $org.$year; //$org = 'COM', $year= '2021'
$condition = "coba.calendar LIKE '$cal%' "; //So it should be like "coba.calendar LIKE 'COM2021%'

$qry = "SELECT coba.field_1, coba.field_2
FROM table_1 coba
WHERE $condition";

And then run the $qry, but I’m getting a Fatal error: Allowed memory size of…

$rs = odbc_exec($link_ifx, $qry); //I'm getting a Fatal error: Allowed memory size of...
while ($row = odbc_fetch_array($ )) {
  $array[] = $row;
}

echo json_encode($array);

But if I do this it works:

$qry = "SELECT coba.field_1, coba.field_2
FROM table_1 coba
WHERE coba.calendar LIKE 'COM2021%'";

Source: Ask PHP

LEAVE A COMMENT