f.ismayil Posted April 24, 2011 Share Posted April 24, 2011 I have such a little code. If I echo $order_date, I receive normal date in YYYY-MM-DD format. But when I use $order_date in mysql query it is not showing me anything. I do not receive any error or warning also. Please help me. $query = "SELECT Product,Amount FROM orders WHERE Date='$order_date'"; $result = mysql_query($query) or die(mysql_error()); while($products_list = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $products_list["Product"] . "</td>"; echo "<td>" . $products_list["Amount"] . "</td>"; echo "</tr>"; } Quote Link to comment https://forums.phpfreaks.com/topic/234603-date-field-problem/ Share on other sites More sharing options...
Jnerocorp Posted April 24, 2011 Share Posted April 24, 2011 try: $query = "SELECT Product,Amount FROM orders WHERE Date='".$order_date."'"; $result = mysql_query($query) or die(mysql_error()); while($products_list = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $products_list["Product"] . "</td>"; echo "<td>" . $products_list["Amount"] . "</td>"; echo "</tr>"; } Quote Link to comment https://forums.phpfreaks.com/topic/234603-date-field-problem/#findComment-1205648 Share on other sites More sharing options...
wildteen88 Posted April 24, 2011 Share Posted April 24, 2011 @Jnerocorp the change you made will not make a difference. Variables within double quotes is perfectly fine. Have a read of this tutorial for working with dates in PHP and MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/234603-date-field-problem/#findComment-1205651 Share on other sites More sharing options...
Pikachu2000 Posted April 24, 2011 Share Posted April 24, 2011 Jnerocorp, that is no different than what the OP posted; adding string concatenation isn't going to fix the problem. Is there a field in the table named 'Date', and if there is, what is its data type? Echo the query string and make sure it contains the values you think it should contain. Quote Link to comment https://forums.phpfreaks.com/topic/234603-date-field-problem/#findComment-1205653 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.