jandrews3 Posted August 25, 2008 Share Posted August 25, 2008 I keep getting the following warning for the code below: Warning: date() expects parameter 2 to be long, string given in /home/temp1/public_html/admin_cpanel.php on line 136 $yer = date('Y'); $query2 = "SELECT * FROM ithf_members"; $result2= mysql_query($query2) or die("Could not perform query: ".mysql_error()); while ($row2 = mysql_fetch_array($result2)){ $pull = date("Y-m-d",$row2['entrydate']); if (substr($pull,0,7) == $yer."-01"){$jan++;} if (substr($pull,0,7) == $yer."-02"){$feb++;} if (substr($pull,0,7) == $yer."-03"){$mar++;} if (substr($pull,0,7) == $yer."-04"){$apr++;} if (substr($pull,0,7) == $yer."-05"){$may++;} if (substr($pull,0,7) == $yer."-06"){$jun++;} if (substr($pull,0,7) == $yer."-07"){$jul++;} if (substr($pull,0,7) == $yer."-08"){$aug++;} if (substr($pull,0,7) == $yer."-09"){$sep++;} if (substr($pull,0,7) == $yer."-10"){$oct++;} if (substr($pull,0,7) == $yer."-11"){$nov++;} if (substr($pull,0,7) == $yer."-12"){$dec++;} } Link to comment https://forums.phpfreaks.com/topic/121319-solved-date-warning/ Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 The error is rather descriptive...you're giving it a string and it wants a long (number). Link to comment https://forums.phpfreaks.com/topic/121319-solved-date-warning/#findComment-625483 Share on other sites More sharing options...
jandrews3 Posted August 25, 2008 Author Share Posted August 25, 2008 Wow! Thanks! I hadn't noticed that. I thought something designated as varchar in a MySQL database could be treated flexibly as any other integer or string. I thought that's what the point was. I changed it from varchar to int and it worked. Thanks! Link to comment https://forums.phpfreaks.com/topic/121319-solved-date-warning/#findComment-625488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.