Jump to content


Photo

DateAdd Help


  • Please log in to reply
3 replies to this topic

#1 urbandsigns.com

urbandsigns.com
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 04 August 2006 - 05:33 PM

I made a flash AutoX game (http://www.gdub.net/games.php). At the end it sends the lap time & number of cones hit to a php page that takes the information, records it in a MySQL database, and posts the scores. The problem is I have to add the lap time + 1 second for each cone. I did some research and found the DateAdd function which in theroy should work, but it doesn't. Below is my code, everything works except the $total2 section with the DateAdd function:

<?
$name = $_GET["name"];
$score = $_GET["score"];
$cones = $_GET["cones"];
$minutes = $_GET["minutes"];
$seconds = $_GET["seconds"];
$milli = $_GET["milli"];
$total = $seconds + $cones - 1;
$total2 = DateAdd('s', $_GET["cones"], $_GET["score"]);
$result = mysql_query("INSERT INTO ***** (name, score, cones, date, total, total2) VALUES ('$name','$score','$cones',Now(),'$minutes:$total:$milli','$total2')") or die(mysql_error()); 
?>


#2 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 04 August 2006 - 06:00 PM

Have you defined the DateAdd() function anywhere in your program
as far as I am aware there is no pre-defined function of that name in PHP.




you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#3 urbandsigns.com

urbandsigns.com
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 04 August 2006 - 06:21 PM

No I didn't, I assumed DateAdd was a PHP function. Guess I better look into it more.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 04 August 2006 - 09:15 PM

I have no idea what these data represent, by MySQL can do a fair bit of date math for you.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users