Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Keep getting syntax error when doing a query


Go to End


1260 Views

Avatar
luuk

Community Member, 15 Posts

9 September 2014 at 7:36pm

Hi,

i would like to do a sqlquery, but no matter what example or other code i use i always get the same syntax error:

Parse error: syntax error, unexpected '$checkIfReceived' (T_VARIABLE), expecting function (T_FUNCTION) on line 15.

Here's the code i use:

$checkIfReceived = DB::query('SELECT Created FROM checkSituationsFormSubmissions WHERE ReceivedSecondEmail == 0');
return $checkIfReceived;

$checkIfReceived = new SQLQuery();
$checkIfReceived->setFrom('checkSituationsFormSubmissions');
$checkIfReceived->selectField('Created');
$checkIfReceived->addWhere('ReceivedSecondEmail' = 0);
$result = $checkIfReceived->execute();

return $result;

I tried to use two different syntaxes but both off them fail. Does anyone have an idea?

thanks in advance.