0

What's wrong with this query?

 $query = $db->query("select username from roomsbooked where username='$_SESSION[username]' and timeslot='$_SESSION[timeslot]' and number='$_SESSION[roomNumberToBook]' and dateofbooking='$_SESSION[dateEntered]'");

The dateofbooking field in the database is a "date" field.

$_SESSION[dateEntered] is defined as:

$_SESSION["dateEntered"] = DateTime::createFromFormat('d/m/Y', $_POST["Date"]);

When the script runs it gets to the query but nothing happens there after.

2
  • Date fields are stored with Y-m-d format in MySQL Commented Dec 9, 2014 at 10:41
  • I've made that change but it's still showing "0000-00-00" in the database field. Commented Dec 9, 2014 at 10:52

1 Answer 1

3

MySQL Doesnt use d/m/Y format, you have to do

DateTime::createFromFormat('Y-m-d', $_POST["Date"]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.