cobusbo Posted November 29, 2015 Share Posted November 29, 2015 Hi, I'm recalling information from my database to show all the birthdays of the specific day but today the 30th of November 2015 I get a list of everyone who is stored in my database showing as if its their birthday. Somewhere I made a mistake my database field is DateTime $querybd = "SELECT Username, pdob FROM Users2"; $resultbd = mysql_query($querybd) or die(mysql_error()); $users = array(); while($rowbd = mysql_fetch_array($resultbd)){ if (date('m-d', strtotime($rowbd['pdob'])) == date('m-d')) $users[] = $rowbd['Username']; } $list = implode('; ', $users); if($list == ""){}else{ echo "<br><b>Todays Birthdays: </b>" . $list . "<br>"; } It worked fine till today Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 29, 2015 Share Posted November 29, 2015 (edited) You are using deprecated code. You need to use PDO with prepared statements or Mysqli. Why are you going through all that code when you can just get the data you want in a query? SELECT column1, column2 FROM table WHERE date_column=CURDATE() You are all over the place with upper and lowercase naming. Use all lowercase separating words with an underscore. Edited November 29, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted November 29, 2015 Solution Share Posted November 29, 2015 SELECT column1, column2 FROM table WHERE date_column=CURDATE() That will only get those who were born today, not whose birthday falls today. SELECT username , pdob , YEAR(CURDATE())-YEAR(pdob) as age FROM table WHERE MONTH(pdob)=MONTH(CURDATE()) AND DAY(pdob)=DAY(CURDATE()) 1 Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 29, 2015 Share Posted November 29, 2015 Ahh, yes, of course. Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 benanamen's main point is probably the issue. Probably your version of php was updated and the mysql_ functions are deprecated and have been removed entirely. You need to either use mysqli_ or pdo, and adjust your code accordingly, but that could be a substantial undertaking, as it should effect your entire code base any place that mysql is being used. Quote Link to comment Share on other sites More sharing options...
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.