I am using the following code:
//Get latest version of regulation related to this CE Group
$rstmp = CustomQuery("
SELECT *
FROM EURegulations
ORDER
BY ValidFrom DESC
LIMIT 1
where CEGroupFk='".$values['CEGroupFk']."'
");
$datatmp = db_fetch_array($rstmp);
The purpose is to return the latest item in that list that is relevant to that foreign key.
I am getting the following message:
- You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where CEGroupFk='5'' at line 1;
- 256;
The array seems to returning good data:
- Array ( [EURegulationReference] => test [EURegulationTitle] => test [ValidFrom] => 2019-06-19 00:00:00 [ValidTo] => 2019-06-28 00:00:00 [Attachment] => [CEGroupFk] => 5 [E...;
- Array ( [EURegulationPk] => 2 ) ;
I am assuming that there is a problem with my customquery code but cannot see it?