Someone helped me with this query in ColdFusion in the forums a while ago(Thread is here). and I'm now trying to use this query in PHP and I can't seem to get it to work. the tables are exactly the same in the database.

ColdFusion:
Code:
<cfquery name="qGetPhoto" datasource="#variables.dsn#">
    SELECT       p.photo_id
    ,            p.photo_file
    ,            p.photo_title
    ,            p.photo_description
    ,            p.photo_keywords
    ,            p.photo_date
    ,            p.photo_views
    ,            a.album_id
    ,            a.album_title
    ,            ( SELECT MIN(photo_id) FROM tbl_photos WHERE photo_album = p.photo_album AND photo_id > p.photo_id ) AS prev_id
    ,            ( SELECT MAX(photo_id) FROM tbl_photos WHERE photo_album = p.photo_album AND photo_id < p.photo_id ) AS next_id
    FROM         tbl_photos AS p
    INNER JOIN   tbl_albums AS a ON p.photo_album = a.album_id
    WHERE        p.photo_id = <cfqueryparam value="#arguments.pid#" cfsqltype="cf_sql_integer" />
</cfquery>
How would I write this in PHP?

Thanks!