Jump to content

PaulRyan

Members
  • Posts

    876
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by PaulRyan

  1. I think I have found a solution... Replace the following $getmin = min($new_date,$reply_date,$finalized_date); With this // Put value into an array $getMin = array($new_date,$reply_date,$finalized_date); //Filter out any NULL or FALSE values including '0' //Then return the lowest value $getMin = min(array_filter($getMin)); Hopefully this will help you karimali831. Thanks, Paul.
  2. Hello rifts, I too am in the process of making a game (Text based MMORPG to be precise) and fell short at the exact same problem. I did however come up with a solution, which I will soon implement myself but read on. Firstly, you should create a table called item_database or whatever you want. This will hold the items within your game and store such details as: item_id - The ID number of the item (unique) item_name - The name of the item (varchar) item_description - A brief description of the item ect (longtext) item_type - The type of item this is, head, torso, legs, shield, weapon, aug, necklace, gloves, boots, potion, collectable card ot whatever. item_attack, item_defence, item_hp - These will be the attributes of the item (int) Any other details you require Secondly, you create a table called player_items or whatever you want. This database will be used to link to player profiles aswell as the item database. Such fields would include: id - A unique identifier (unique) main_item_id - The Item ID number from the item_database that this represents (int) player_id - The ID number of the player that owns the item (int) Other details could be whether the item is upgraded, or how rare it is ect. Finally, and the users database add some fields such as: head_slot - The id number of the item in the player_items database that is in this players head slot (int) Then the databases would work something like the following: // Lets fetch the head_slot ID Number here $myQuery1 = mysql_fecth_assoc(mysql_query("SELECT head_slot FROM user_database WHERE user_id='$user_id' LIMIT 1")); // Use the head_slot ID number to select the item from the player_items database $myQuery2 = mysql_fetch_assoc(mysql_query("SELECT main_item_id FROM player_items WHERE id='$myQuery1[head_slot]' LIMIT 1")); // Use the item_id number from the previous query // Now we select the item that matchs the item_id from the main item_database $myQuery3 = mysql_fetch_assoc(mysql_query("SELECT item_id FROM item_database WHERE item_id='$myQuery2[item_id]' LIMIT 1")); Hopefully this will make some sense to you and can use this to help with you situation. (I just hope I havent written all this for nothing ) Thanks, Paul.
  3. Ohh right I see, could you give me some example data that will be passed from the folling fields from your database: $ds['new_date'] $ds['reply_date'] $ds['finalized_date'] This may help me in understanding your situation a little more. Thanks, Paul.
  4. Hello karimali831, I used to have the same problem a while ago, so I decided to create a function to fix the problem. function returnTime($value) { $timeDiff = time()-$value; // Get the difference in time $fullYears = floor($timeDiff/365.2422/24/60/60); // Set the amount of years since $value $fullDays = floor($timeDiff/24/60/60)-($fullYears*365); // Set the amount of dayss since $value $fullHours = floor($timeDiff/60/60)-($fullDays*24)-($fullYears*365*24); // Set the amount of hours since $value $fullMinutes = floor($timeDiff/60)-($fullHours*60)-($fullDays*24*60)-($fullYears*365*24*60); // Set the amount of minutes since $value $fullSeconds = floor($timeDiff)-($fullMinutes*60)-($fullHours*60*60)-($fullDays*24*60*60)-($fullYears*365*24*60*60); // Set the seconds of years since $value // Now we check the difference and output correct timescale if($timeDiff >= '31536000') { return ''.$fullYears.' year(s)'; } else if($timeDiff >= '86400' && $timeDiff < '31536000') { return ''.$fullDays.' day(s)'; } else if ($timeDiff >= '3600' && $timeDiff < '86400') { return ''.$fullHours.' hour(s)'; } else if ($timeDiff >= '60' && $timeDiff < '3600') { return ''.$fullMinutes.' minute(s)'; } else if ($timeDiff < '60') { return ''.$fullSeconds.' second(s)'; } } Simple call returnTime('Your Timestamp') wherever you want and it will show time since date in the correct format. Hopefully this can help, if not let em know. Thanks, Paul.
  5. <?php //let's start our session, so we have access to stored data session_start(); include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //let's create the query $query = 'INSERT INTO subscriptions (name, email_address, membership_type, terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_data) VALUES ( "' . $_SESSION[$name] . '", ' . $_SESSION[$email_address] . '", ' . $_SESSION[$membership_type] . '", ' . $_SESSION[$terms_and_conditions] . '", ' . $_POST[$name_on_card] . '", ' . $_POST[$credit_card_number] . '", ' . $_POST[$credit_card_expiration] . ')'; if (isset($query)) { $result = mysql_query($query, $db) or die(mysql_error($db)); } ?> <p>Done!</p> </body> </html> Well I can't believe no-one else spotted this, or am I missing the point? Look on the very last line on your posted code for '?>'... You added a close PHP tag but yet you haven't opened it, copy and paste the code above hopefully it will fix the error. Thanks, Paul Ryan.
×
×
  • 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.