PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Tue Jun 14, 2005 4:41 pm
so the $themonth and $theyear output correctly giving 06 and 2005. when it inserts them into the table StatsByMonth, the month field is 06 and the year field is 127. Help?
Code: Select all
$themonth = date("e;m"e;);
$theyear = date("e;Y"e;);
print $themonth.'<br>'.$theyear."e;<br>"e;;
$result = mysql_query( "e;SELECT * FROM StatsByMonth WHERE month='$themonth' AND year='$theyear'"e; );//
$row=mysql_fetch_array($result); //Store Record Of Data in $row
if ($rowї'id'] == "e;"e;)
{
mysql_query ("e;INSERT INTO StatsByMonth(Visitors, PageViews, Downloads, month, year) VALUES ('0', '0', '0', '$themonth', '$theyear')"e;)
or die(mysql_error());
print 'boo';
}
else
{
print 'woo';
}
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Tue Jun 14, 2005 5:09 pm
i needed to change the year field into a varchar instead of tinyint.
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Tue Jun 14, 2005 5:37 pm
The overhead on the database would be smaller if you made it an int instead of a varchar.
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Tue Jun 14, 2005 5:44 pm
well it wasnt working with int. so i had to make it a char.
Syranide
Forum Contributor
Posts: 281 Joined: Fri May 20, 2005 3:16 pm
Location: Sweden
Post
by Syranide » Wed Jun 15, 2005 12:33 am
tinyint = -128 to 127
try reading the documentation
you need to go for mediumint or so, but I recommend saving year, month and the rest as one field (int).