Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.
Moderator: General Moderators
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Sun Jul 21, 2002 7:56 pm
Ok, here's match #2:
Sudden death (free for all)
Max lines per edit: 5
Time limit: None
http://www.zend.com/codex.php?id=309&single=1
Code: Select all
<?php
function getAgeByDate($iMonth, $iDay, $iYear) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
}
?>
enygma
Site Admin
Posts: 175 Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx
Post
by enygma » Mon Jul 22, 2002 7:30 am
Alright - so who thinks this would make for a good site on it's own? I spent the weekend outlining something that I think would work, but I need to get it all typed up and posted so that you guys could take a look at it.
Basically, it would work the same way as this would, just with more structure. There would be the possibility of "open matches" where anyone could view/join in as long as they have a username on the site, as well as private matches that would be "view-only" to everyone else except those involved.
The site would take care of storing the "turns" in a database and emailing the other people when it was their turn to go...
I think something like this could really take off, and I'd love to work on it. I was going to start it up and then present it to you all, but I figured I'd get your opinion first and see how it went from there.....
Ideas? Suggestions?
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Mon Jul 22, 2002 7:40 am
yes, this really would take off, it's fun. and you could collect the final scripts and archive them, or something
hex
Forum Commoner
Posts: 92 Joined: Sat Apr 20, 2002 3:20 am
Location: UK
Post
by hex » Mon Jul 22, 2002 7:53 am
Yeah, that would be great. Have different sections like:
PHP
-- Sudden Death
-- One-On-One
-- (etc)
ASP
-- Sudden Death
-- One-On-One
-- (etc)
JSP
-- Sudden Death
-- One-On-One
-- (etc)
And so on, as well as perhaps a seperate general discussion forum.
As for the archive, that would be pretty cool too. Make it so users can post the final code instead of the admins having to do it all. I think one of the reasons this 'game' was started was to develop code...
hex
Forum Commoner
Posts: 92 Joined: Sat Apr 20, 2002 3:20 am
Location: UK
Post
by hex » Mon Jul 22, 2002 7:58 am
Code: Select all
<?php
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return "Missing argument.";
}
}
?>Began error trapping.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Mon Jul 22, 2002 8:07 am
Code: Select all
<?php
$link = mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
mysql_query("INSERT INTO ages (age) values ('$iYears')");
return $iYears;
} else {
return "Missing argument.";
}
}
?>
we might as well record it...
hex
Forum Commoner
Posts: 92 Joined: Sat Apr 20, 2002 3:20 am
Location: UK
Post
by hex » Mon Jul 22, 2002 8:13 am
Code: Select all
<?php
// Example: storeAge(getAgeByDate(2,19,1986))
function storeAge($age) {
$link = mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
mysql_query("INSERT INTO ages (age) values ('$age')");
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return "Missing argument.";
}
}
?>
hex
Forum Commoner
Posts: 92 Joined: Sat Apr 20, 2002 3:20 am
Location: UK
Post
by hex » Mon Jul 22, 2002 8:24 am
Just out of interest protokol, did you nick that script idea from the SitePoint Forums, or is jsut conincidence that they started the same match?!
samscripts
Forum Commoner
Posts: 57 Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK
Post
by samscripts » Mon Jul 22, 2002 10:01 am
why not have an ASP vs PHP vs JSP vs PERL etc section - someone posts something in one language, others have to create the same in the other languages? Could be quite useful for people with knowledge of one trying to learn another?
Sam
Hex Wrote:
Yeah, that would be great. Have different sections like:
PHP
-- Sudden Death
-- One-On-One
-- (etc)
ASP
-- Sudden Death
-- One-On-One
-- (etc)
JSP
-- Sudden Death
-- One-On-One
-- (etc)
llimllib
Moderator
Posts: 466 Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD
Post
by llimllib » Mon Jul 22, 2002 12:41 pm
let me try my hand at this:
Code: Select all
<?php
function storeAge($age) {
//provide error handling on DB errors
$link = @mysql_connect("localhost", "user", "pass")
or die("connect failed");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("query failed");
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return "Missing argument.";
}
}
?>
Just a question: what about the 80-char per line rule? the original post violated it.
duke9
Forum Newbie
Posts: 7 Joined: Thu May 23, 2002 4:17 pm
Post
by duke9 » Mon Jul 22, 2002 2:46 pm
Since it's not generally considered polite to ask a woman how old she is ..
Code: Select all
<?php
function storeAge($age) {
//provide error handling on DB errors
$link = @mysql_connect("localhost", "user", "pass")
or die("connect failed");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("query failed");
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return "Missing argument.";
}
}
// f_ prefix marks variables from a form
$age = getAgeByDate($f_mon,$f_day,$f_year);
if (is_int($age)) {
sprint("You are $age years %s.",($f_gender == "female") ? "young" : "old");
};
?>
terryf
Forum Newbie
Posts: 1 Joined: Mon Jul 22, 2002 2:55 pm
Post
by terryf » Mon Jul 22, 2002 2:55 pm
Code: Select all
<?php
function storeAge($age) {
//provide error handling on DB errors
$link = @mysql_connect("localhost", "user", "pass")
or die("connect failed");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("query failed");
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return "Missing argument.";
}
}
// functions are nice
function getAgeString($sGender, $iMonth, $iDay, $iYear) {
$age = getAgeByDate($iMonth, $iDay, $iYear);
if (is_int($age)) {
return "You are $age years ".(($sGender == "female") ? "young" : "old");
};
}
?>
hex
Forum Commoner
Posts: 92 Joined: Sat Apr 20, 2002 3:20 am
Location: UK
Post
by hex » Tue Jul 23, 2002 5:15 am
Code: Select all
<?php
function storeAge($age) {
if ($age) {
$link = @mysql_connect("localhost", "user", "pass")
or die("<b>Database connect failed.</b>");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("<b>Database query failed.</b>");
}
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return false;
}
}
function getAgeString($sGender, $iMonth, $iDay, $iYear) {
$age = getAgeByDate($iMonth, $iDay, $iYear);
if (is_int($age)) {
return "You are $age years ".(($sGender == "female") ? "young" : "old");
}
}
?>
DSM
Forum Contributor
Posts: 101 Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA
Post
by DSM » Tue Jul 23, 2002 8:27 am
Code: Select all
<?php
function storeAge($age) {
if ($age) {
$link = @mysql_connect("localhost", "user", "pass")
or die("<b>Database connect failed.</b>");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("<b>Database query failed.</b>");
}
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return false;
}
}
function getAgeString($sGender, $iMonth, $iDay, $iYear) {
$age = getAgeByDate($iMonth, $iDay, $iYear);
if (is_int($age)) {
return "You are $age years ".(($sGender == "female") ? "young" : "old");
} else{
return false;
}
}
?>
llimllib
Moderator
Posts: 466 Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD
Post
by llimllib » Tue Jul 23, 2002 8:37 am
Code: Select all
<?php
function storeAge($age) {
if ($age) {
$link = @mysql_connect("localhost", "user", "pass")
or die("<b>Database connect failed.</b>");
mysql_select_db("db");
$result = @mysql_query("INSERT INTO ages (age) values ('$age')")
or die("<b>Database query failed.</b>");
}
}
function getAgeByDate($iMonth, $iDay, $iYear) {
if (!empty($iMonth) && !empty($iDay) && !empty($iYear)) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;
} else {
return false;
}
}
//seems like everywhere but the USA a 20-year old (like me) can drink...
function isLegalToDrink($iMonth, $iDay, $iYear, $iCountry) {
$age = getAgeByDate($iMonth, $iDay, $iYear);
if(is_int($age) && (($age > 18 && strcasecmp($iCountry,"USA")) || ($age > 21 && !strcasecmp($iCountry,"USA"))))
return "You are legal to drink alcohol";
else
return "You have " . (21 - $age) . " year(s) left until you can drink";
}