jeff5656 Posted November 20, 2008 Share Posted November 20, 2008 In my database table I have a variable called which_month. The values are November, December, etc. I want the following code to pull the record with with the current month, but when I run this code I get: "Invalid query: Unknown column 'November' in 'where clause'" <?php include ("../connectdb.php"); $curr_month = date (F); $consultsq1 = "SELECT * FROM `staffsched` WHERE `which_month` = $curr_month"; $result = mysql_query ($consultsq1) or die ("Invalid query: " . mysql_error ()); $row = mysql_fetch_array ($result); ?> Quote Link to comment Share on other sites More sharing options...
marcus Posted November 20, 2008 Share Posted November 20, 2008 $consultsql = "SELECT * FROM `staffsched` WHERE `which_month`='".$curr_month."'"; Quote Link to comment Share on other sites More sharing options...
revraz Posted November 20, 2008 Share Posted November 20, 2008 Means you forgot single quotes around the $curr_month variable. Quote Link to comment Share on other sites More sharing options...
marcus Posted November 20, 2008 Share Posted November 20, 2008 What revraz said It's common to forget quotes, just use them when you can to escape information, makes error checking a lot easier 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.