Make your own PHP adoptables system

Need help with the site/forum/pets? Ask questions and get help from other members here.

Re: Make your own PHP adoptables system

Postby Turquoise » Sat Aug 28, 2010 3:39 pm

I am just going to keep things the way they are now. I just made new lineart this month, so it really doesn't matter if old adoptables don't show. I don't have a HUGE amount of members anyway, and I'm sure they won't mind. I just don't want to mess anything else up, and I'm happy with the site right now anyways. Thanks for all of your help. ^^
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Turquoise » Thu Sep 02, 2010 4:41 am

I hope this is the last thing I have to bother you with. xD

When I adopted a pet earlier it went straight to adult stage. What is wrong with the coding from adopt.xml?:

Code: Select all
<adoptable id="32">
    <variation id="1" chance="2.0">
        <age image="bone32.png" />
        <age date="604800" image="puppy32a.png" />
        <age date="1814400" image="adult32a.png" />
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Nick » Thu Sep 02, 2010 7:40 am

If you made that last change I suggested (allowing them to grow by age or date), you should be using age="xxx" instead of date="xxx" :) (and the code I suggested would have age in days, not seconds).
User avatar
Nick
Admin
 
Posts: 6349
Joined: Thu Jul 03, 2008 2:40 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Turquoise » Thu Sep 02, 2010 7:59 am

Nick wrote:If you made that last change I suggested (allowing them to grow by age or date), you should be using age="xxx" instead of date="xxx" :) (and the code I suggested would have age in days, not seconds).


Oh, haha, I knew it was something like that. Thanks. xD
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Turquoise » Thu Sep 02, 2010 10:43 am

I have a problem with: http://laughingwolflane.comze.com/elloello.php (It is the coding I would use for "mainpage.php", but I don't want anyone adopting to see the adult stage, so I put the coding on a "secret" page. D=)

All of the pets that can be adopted are showing below the page, and I can't get them back where the were. (Do you remember from where they were before?)

Also, I changed the coding to this for one of my pets, but it still goes at adult stage when I adopt it:
(You can also see when you adopt from mainpage.php)

Code: Select all
    <variation id="3" chance="2.0">
        <age image="bone30.png" />
        <age age="9" image="dogpuppy.png" />
        <age age="22" image="dogadult.png" />
    </variation>


What am I doing wrong?
Thanks.
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Nick » Thu Sep 02, 2010 6:38 pm

You're missing a <table> tag around the TRs that have the pets in them, at the moment you've got those rows being part of your overall layout table which is probably not what you want.

Show the code from simple.php which is checking the date and time.
User avatar
Nick
Admin
 
Posts: 6349
Joined: Thu Jul 03, 2008 2:40 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Turquoise » Fri Sep 03, 2010 2:02 am

Thanks. :)

Here is the coding for simple.php:

Code: Select all
<?php

                //Tell the browser that we are sending it a PNG image to display
                header("Content-Type: image/png");

                require("adopttools.php");

                $idofpet = $_GET['idp'];

                $db2 = mysql_connect('mysql5.000webhost.com', 'a3459659_122195', 'password goes here');
                if (!$db2) {
                    die('no connection possible: ' . mysql_error());
                }

                $x2 = mysql_select_db('a3459659_122195');

                $sql2 = "SELECT ID,UNIX_TIMESTAMP(date),petID,varID FROM adoptables WHERE ID=$idofpet;";
                $result2 = mysql_query($sql2) or die(mysql_error());

                $row = mysql_fetch_row($result2);

                //Find the variation with the given adoptable id ('a') and variation id ('v')
                $variation=find_variation($row[2], $row[3]);

                //Decide which of the ages we want to show for the adoptable
                     
                $pickedAge=NULL; //We'll store the age we eventually pick into the variable $pickedAge
                     
                /* Check the ages in order. The age we end up picking will be the last age
                * in the file where the current date is after the 'date' attribute
                */

                foreach ($variation->age as $age) {
                if (!isset($age['date']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {
                   
                      $pickedAge=$age;
                   }
                }

                //Now that we've picked the age, display the image that that age uses
                readfile($pickedAge['image']);   

                exit();

                ?>
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Nick » Fri Sep 03, 2010 2:53 pm

Ah, I see the problem now. Change this line:

Code: Select all
if (!isset($age['date']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {

To:

Code: Select all
if (!isset($age['date']) && !isset($age['age']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {
User avatar
Nick
Admin
 
Posts: 6349
Joined: Thu Jul 03, 2008 2:40 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Turquoise » Fri Sep 03, 2010 2:57 pm

It's working perfectly now!

Thank You! ^^
Image
User avatar
Turquoise
 
Posts: 2131
Joined: Sun Sep 21, 2008 9:12 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby kleinerdrache » Mon Sep 13, 2010 6:13 am

This is awesome! :D Thanks Nick. Maybe when I finish up mine, someday it'll be as good as Cs. ;)
Image
----
Hi, I'm KD. I'm a software engineer that likes reading books and playing video games
Send me trades or messages anytime! ^^
----

Image
User avatar
kleinerdrache
 
Posts: 6173
Joined: Thu May 13, 2010 8:00 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Who is online

Users browsing this forum: alolan vulpix and 2 guests