divinedesigns1 Posted October 11, 2012 Share Posted October 11, 2012 ok, im recreating my website into a dymanic website "its a static website atm" and im stuck on displaying the amount of messages i get from the contact form when try my code it display there was 0 msg when there was 2 msg this is my code $date = date('Y, m d');$msg = mysqli_query($con, "SELECT * FROM contact WHERE date='$date'") or die('Error: ' . mysqli_error($con));$nums = mysqli_num_rows($msg);if($nums > 0){echo $nums;} and this is the structure in my dbid int(11)fn varchar(255)em varchar(255)country varchar(255)city varchar(255)others textdate date 0000-00-00but its not working atm, so can someone point me in the right direction by hinting me on my mistake Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2012 Share Posted October 11, 2012 Format the date like it shows, 0000-00-00. Link to comment Share on other sites More sharing options...
niche Posted October 11, 2012 Share Posted October 11, 2012 What error messages are you getting? Link to comment Share on other sites More sharing options...
Don E Posted October 11, 2012 Share Posted October 11, 2012 $date = date('Y, m d'); displays as: 2012, 10 11 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted October 11, 2012 Author Share Posted October 11, 2012 Format the date like it shows, 0000-00-00.ok ill try that $date = date('Y, m d'); displays as: 2012, 10 11 no errors Link to comment Share on other sites More sharing options...
Don E Posted October 12, 2012 Share Posted October 12, 2012 (edited) I meant maybe why you're not getting any results is because $date is being displayed as 2012, 10 11 when the date column contains dates that display like this instead: 2012-10-11. So try this: $date = date('Y-m-d'); Edited October 12, 2012 by Don E Link to comment Share on other sites More sharing options...
divinedesigns1 Posted October 12, 2012 Author Share Posted October 12, 2012 $date = date('Y, m d'); displays as: 2012, 10 11 yeah i though that would work, since its 0000-00-00 in the dbI meant maybe why you're not getting any results is because $date is being displayed as 2012, 10 11 when the date column contains dates that display like this instead: 2012-10-11. So try this: $date = date('Y-m-d'); alrite ill try that one see sup Link to comment Share on other sites More sharing options...
divinedesigns1 Posted October 12, 2012 Author Share Posted October 12, 2012 ok i figure out why it wasnt working, for some reason, $date(Y-m-d) was displaying 2012-10-12 once i minus "a day" from the date() it displays 2012-10-11 which is the correct date, thanks for the help guys Link to comment Share on other sites More sharing options...
birbal Posted October 12, 2012 Share Posted October 12, 2012 date has second parameter which takes timestamp as its parameter. by default it is current timestamp. so it is showing you the correct date Link to comment Share on other sites More sharing options...
justsomeguy Posted October 12, 2012 Share Posted October 12, 2012 It's using the time settings on the server, whatever that is set to. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted October 13, 2012 Author Share Posted October 13, 2012 date has second parameter which takes timestamp as its parameter. by default it is current timestamp. so it is showing you the correct dateoh alriteIt's using the time settings on the server, whatever that is set to.that explains why i kept getting the wrong date thanks guys Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now