Jump to content

Problem with select and dates / week of year


bschultz

Recommended Posts

I need to query a database and select a list of names whose birthday is next week.  The dates are in the database in Y-M-D format (2009-11-23). 

 

Here's my code...

 

$sql = "SELECT * FROM kids WHERE DATE_SUB(WEEKOFYEAR(),INTERVAL +1) = age"; 
$dbq = mysql_query($sql,$dbc); 
//now spit out the results 
while ($row = mysql_fetch_array($dbq)) {  
echo "".$row[name]." ".$row[address]." ".$row[address]." ".$row[city]." ".$row[state]." ".$row[phone]." ".$row[email]." ".$row[age]."&nbsp<br />"; 
} 
echo "<br />"; 
?>

 

I'm getting this error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 13

 

Line 13 is this line...  while ($row = mysql_fetch_array($dbq)) { 

 

Any ideas where I'm messing up the query?

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.