Jump to content

Pi_Mastuh

Members
  • Posts

    233
  • Joined

  • Last visited

    Never

Everything posted by Pi_Mastuh

  1. a different value. Each row has an ID, a value, and a 2nd value. One of the 2 non-ID values is above zero and the other is zero.
  2. I want to have it seach for an ID number in a table and if it finds it then to check if a value is above zero, if it is then dissplay error message one. If it's not, see if a second value is above zero and if it is display error message 2. How do I do that?
  3. That's what it was. Thanks
  4. I'm getting Parse error: parse error, unexpected $ in /homepages/20/d175171605/htdocs/reg/secure/use2.php on line 226 but all line 226 is is ?>. There's no $. Does anyone know what's wrong?
  5. Thank you, I thought it was something along those lines.
  6. No, A dropdown list with something like Cat, Dog, etc. And whn you click dog, for example, it stores $shopImageLink as dog.jpg.
  7. I have this piece of code: <textarea name=shopImageLink cols=30>$shopImageLink</textarea> It declares the variable by what you type in or somethin like that but i want to change it to a dropdown bow that displays a name and declares the variable as a url based on the name. I don't know exactly what the code does, but you're suppossed to enter a url of a picture. i want them to be able to choose from a list of pictures.
  8. Thank you for all your help  ;D. I love these forums. Last month I would have looked at these scripts and said "huh...?" and now I actualy know what they mean and how to write them and everything  ;D
  9. I got it to work. i simply added "as lastDatefed" to my query, the variable wasn't declared.
  10. The problem is obviously that it's not recieving the variable correctly. Is there an error in my SQL query or something?
  11. It produces Date last fed Date right now 2006-09-18 22:49:50 And the difference is 1 days But I'm POSITIVE that the lastdatefed for the pet with an ID of 1 is 2006-09-15 10:30:20. I just copied that from the database so I know it's right.
  12. do you see anything wrong with my code?
  13. I got it to round but now it's not working at all, it just says that the lastdatefed was today when it's the 15th. I modified the test code to include the lastdatefed from the database. Here's what I have: [code]<?php include ("secure/config.php"); include ("secure/dbinfo.php"); $query = "SELECT * FROM chibifriendspets WHERE monopetID = '1'";     $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $lastDatefed = $query_data['lastDatefed']; $lastDatefed = date("Y-m-d H:i:s",strtotime("$lasteDatefed")); // your database value $then = strtotime($lastDatefed); // in seconds since the start of time = 1158540243 echo "Last Date Fed is ". $then. " seconds<br/>"; // outputs $right_now = time(); // in seconds since the start of time varies depending on when you test echo "Right now is ". $right_now. " seconds<br/>"; // outputs $timesincefed = $right_now - $then; echo "# seconds since fed is ". $timesincefed. " seconds<br/>"; $dayssincefed = number_format($timesincefed/86400,2); $days = round($dayssincefed); echo "Date last fed ". $lastDatefed. "<br/>Date right now ". date("Y-m-d H:i:s"). "<br/>And the difference is ". $days. " days"; ?> [/code]
  14. That's what I'm saying, it should be 1 but it says 0. Do you know why it's doing that?
  15. I think the round script messes it up, now it says Last Date Fed is 1158540243 seconds Right now is 1158626813 seconds # seconds since fed is 86570 seconds Date last fed 2006-09-17 20:44:03 Date right now 2006-09-18 20:46:53 And the difference is 0 days the difference should be 1 day because it was .9
  16. I've looked over it again and again and it looks right, but it's not working  :-\
  17. Last Date Fed is 1158540243 seconds Right now is 1158625156 seconds # seconds since fed is 84913 seconds Date last fed 2006-09-17 20:44:03 Date right now 2006-09-18 20:19:16 And the difference is 0.98 days
  18. Does anyone know why it's being so weird?
  19. They are, that's why I'm confused. The pet i'm testing it on has the lastDatefed stored as: 2006-09-17 20:44:03 in the MySQL database
  20. I've gone over it again and again and i dont see what's wrong.  ???
  21. Here's my entire code. I dont think theres anything wrong with it beyond the time piece of it, because it worked until I changed your example time to my variable $lastDatefed, which is the same format. It says Date last fed -1 Date right now 2006-09-18 16:52:21 And the difference is 13 days and changes their hunger to 13 [code]<? session_start(); $session=session_id( ); include ("secure/config.php"); include ("secure/dbinfo.php"); include ("secure/petDetails2.php"); ?> <? $monopetID = $_POST['monopetID']; $query = "SELECT * FROM chibifriendspets WHERE monopetID = '$monopetID'";     $result = mysql_query($query ,$connection); $query_data = mysql_fetch_array($result); $lastDatefed = $query_data['lastDatefed']; $hunger = $query_data['hunger']; $datelastfed = strtotime($lastDatefed); // for example $then = strtotime($datelastfed); // in seconds since the start of time $right_now = time(); // in seconds since the start of time $timesincefed = $right_now - $then; $dayssincefed = number_format($timesincefed/86400,2); $dayssincefed2 = round($dayssincefed); echo "Date last fed ". $then. "<br/>Date right now ". date("Y-m-d H:i:s"). "<br/>And the difference is ". $dayssincefed2. " days"; if ($lastDatefed == $right_now) { $hunger2 = $hunger; } elseif ($hunger2 > 9) { $hunger2 = 9; } else { $hunger2 = $dayssincefed2; } $query = "UPDATE chibifriendspets SET hunger = '$hunger2' WHERE monopetID = '$monopetID'";     $result = mysql_query($query ,$connection); ?> <html> <head> <title>My Pet, <? print $monopetName; ?></title> </head> <body style="text-align: center"> <BR><table width="751" border="0" cellspacing="0" cellpadding="0">   <tr>     <td colspan="2" height="347" valign="top">       <table width="200" border="1" cellspacing="0" cellpadding="0" bgcolor="blue" bordercolor="#000066">         <tr>           <td align=center>             <table width="200" border="0" cellspacing="0" cellpadding="0">               <tr align=center bgcolor="blue">                 <td align=center bgcolor="blue">                   <div align="center"><font face=Arial, Helvetica, sans-serif size=3 color="#FFFFFF"><b>                     <? echo $monopetName; ?>                     </b></font></div>                 </td>               </tr>               <tr bgcolor="#FFFFFF" align=center>                 <?                    print "<td width=35 align=center><div align='center'><img src=$monopetSpecies.jpg align=center></div></td>"; ?>               </tr>             </table>           </td>         </tr>       </table>       <p align="center"><BR>       </p>       <table width="205" border="1" cellspacing="0" cellpadding="0" bordercolor="#000066">         <tr>           <td><table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">             <tr bgcolor="blue">               <td height="10" colspan="2"><div align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Pet                 Vitals</b></font></div></td>             </tr>             <tr>               <td width="99" height="10">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Health:</font></td>               <td width="101" height="10">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1"> &nbsp;100% </font></td>             </tr>             <tr>               <td height="19">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Pet                 Status:</font></td>               <td height="19">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Happy</font></td>               </tr>             <tr>               <td width="99" height="19">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Hunger: </font></td>               <td width="101" height="19">               <p align="center"><font face="Arial, Helvetica, sans-serif" size="1">   &nbsp;<? if ($hunger2 == "0")   { echo "Stuffed"; } elseif ($hunger2 == "1")   { echo "Full"; } elseif ($hunger2 == "2") { echo "Satiated"; } elseif ($hunger2 == "3") { echo "Not Hungry"; } elseif ($hunger2 == "4") { echo "<font color=red><b>Hungry</b></font>"; } elseif ($hunger2 == "5") { echo "<font color=red><b>Very Hungry</b></font>"; } elseif ($hunger2 == "6") { echo "<font color=red><b>Famished</b></font>"; } elseif ($hunger2 == "7") { echo "<font color=red><b>Starving</b></font>"; } elseif ($hunger2 == "8") { echo "<font color=red><b>Ravenous</b></font>"; } else { echo "<font color=red><b>Dying</b></font>"; } ?> </font></td>               </tr>           </table></td>         </tr>       </table>       <p align="center">       <BR>       </p>       <div align="center"></div>     </td>     <td width="10" height="347">     <p align="center"></td>     <td width="505" height="347" valign="top" align="center">       <table width="500" border="1" cellspacing="0" cellpadding="0" bordercolor="#000066">         <tr>           <td height="111">             <table width="500" border="0" cellspacing="0" cellpadding="0" bordercolor="#000066" height="108">               <tr>                 <td colspan="2" bgcolor="blue" height="28"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="3" color="#FFFFFF"><b>Pet                     Details</b></font></div></td>               </tr>               <tr>                 <td width="150" height="16">                 <p align="center"><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Name:</font></td>                 <td width="302" height="16"><font face="Arial, Helvetica, sans-serif" size="2">                   <? echo $monopetName;?> </font></td>               </tr>               <tr>                 <td width="150" bgcolor="ebebeb" height="16">                 <p align="center"><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Species:</font></td>                 <td width="302" bgcolor="ebebeb" height="16"><font face="Arial, Helvetica, sans-serif" size="2">                   <? echo $monopetSpecies;?> </font></td>               </tr>               <tr>                 <td width="150" height="16">                 <p align="center"><font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Owned                   Since:</font></td>                 <td width="302" height="16"><font face="Arial, Helvetica, sans-serif" size="2">                   <? echo $monopetDOB;?> </font></td>               </tr>               <tr bgcolor="#ebebeb">                 <td height="16">                 <p align="center"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;Pet                   Level:</font></td>                 <td height="16"><font face="Arial, Helvetica, sans-serif" size="2">                   <? echo $monopetLevel;?> </font></td>               </tr>               <tr>                 <td height="16">                 <p align="center"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;Intelligence:</font></td>                 <td height="16"><font face="Arial, Helvetica, sans-serif" size="2">                   <? echo $monopetPoints;?> </font></td>               </tr>             </table>           </td>         </tr>       </table>           <br>       <br>     </td>   </tr> </table> <table width="700" border="0" cellspacing="0" cellpadding="0">   <tr>     <td>       <div align="center"> </div>     </td>   </tr>   <tr>     <td>       <div align="center"><a href="javascript:window.close();">Close This Window</a>       </div>     </td>   </tr> </table> <p>&nbsp;</p> </html> [/code]
  22. I added a round function and added the variable to get the last date fed from the database and it's just putting it to 0 and not showing the lastDatefed. [code]$datelastfed = $lastDatefed; // for example $then = strtotime($datelastfed); // in seconds since the start of time $right_now = time(); // in seconds since the start of time $timesincefed = $right_now - $then; $dayssincefed = number_format($timesincefed/86400,2); $dayssincefed2 = round($dayssincefed); echo "Date last fed ". $datelastfed. "<br/>Date right now ". date("Y-m-d H:i:s"). "<br/>And the difference is ". $dayssincefed2. " days";[/code]
  23. Which would i use to compare 2 dates?
  24. Y-m-d H:i:m so yyyy-mm-dd hh:mm:ss What's the link to the PHP manual again?
  25. It still is set to 0 and won't change, i echoed $timespan and got this: 13409.08568287 Which is very wrong. I'm trying to get the ammount of days between today and the lastdatefed, how do I do that?
×
×
  • 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.