SELECT PaymentId, Amount, A.Credits, D.PaymentStatus, C.PaymentMethod, A.PaymentStatus AS PaymentStatusId, PaymentDtTm, Currency, A.Vat, InvoiceFlatFee FROM tbl_gf_payment_status D, tbl_gf_payments A LEFT JOIN tbl_gf_payment_methods C ON (A.PaymentMethod = C.PaymentMethodId) WHERE A.PaymentStatus = D.PaymentStatusId AND ByAdmin = '1' AND A.UserId = ORDER BY PaymentId DESC LIMIT 0, 50

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY PaymentId DESC LIMIT 0, 50' at line 3