ckbis1 Posted May 9, 2012 Report Posted May 9, 2012 Hi I need to create a pdf report of one of my tables in my database, creating the pdf was easy just used fpdf, but what i am struggling with now is trying to generate that report on data for the past 30 days (i am trying to make a monthly report), my snap shot of my code follows: " echo $date = date("Y-m-d") ; echo $date2 = "select(DATESUB($date, INTERVAL 31 DAY)"; $pdf->Table("select j_num, building,room, description,reason, type, contractors, staff, start_time, end_time, cost, note FROM job WHERE completed = 'yes' BETWEEN $date and $date2 ",$prop); $pdf->Output(); ?> " the first echo gives me this - "2012-05-09" which is right i need the system date the second echo gives me this - "select(DATESUB(2012-05-09, INTERVAL 31 DAY)" which is wrong it should be minusing 30days from the system date THIS IS THE ENTIRE ERROR THAT I GET IN MY BROWSER: 2012-05-09select(DATESUB(2012-05-09, INTERVAL 31 DAY)Error: 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 'select(DATESUB(2012-05-09, INTERVAL 31 DAY)' at line 1 Query: select j_num, building,room, description,reason, type, contractors, staff, start_time, end_time, cost, note FROM job WHERE completed = 'yes' BETWEEN 2012-05-09 and select(DATESUB(2012-05-09, INTERVAL 31 DAY) is there something wrong with my syntax? well i guess its kinda obvious there is, but what and any suggestions on how to fix it Thanx Chris Quote
falkencreative Posted May 10, 2012 Report Posted May 10, 2012 If I understand everything correctly, $date2 is incorrect -- you have two opening parenthesis, but only one closing parenthesis. That's at least the obvious solution, though perhaps there will be more issues after that is fixed. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.