I am converting a site from ColdFusion to PHP.
When I run this query:
$query = 'SELECT TOP e.date
,e.startTime
,e.endTime
,e.title
,e.details
,l.name
,e.room
FROM
WWW.dbo.Events e
LEFT OUTER JOIN
WWW.dbo.Locations l
ON e.locationId = l.locationId
WHERE
WHERE e.date BETWEEN GETDATE() and DATEADD(month, 6, GETDATE())
ORDER BY
ORDER BY date ASC';
I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'e'.' in C:\inetpub\wwwroot\db2.php
:67 Stack trace: #0 C:\inetpub\wwwroot\db2.php
(67): PDO->query('SELECT TOP e.da...') #1 {main} thrown in C:\inetpub\wwwroot\db2.php
on line 67
Any help would be appreciated.
FROM
WWW.dbo.Events e
LEFT OUTER JOIN WWW.dbo.Locations l
Should be:
FROM
WWW.dbo.Events AS e
LEFT OUTER JOIN WWW.dbo.Locations AS l