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 qhost » Sat Feb 14, 2009 11:48 pm

Lady wrote:Okay, I have to ask.. How do you make the adoptables grow after a certain amount of days instead of on a certain date? I like the idea of people being able to grab the adopts the entire time they're up until they are taken down, rather than when I have to remove them because they're about to grow.

It's basically how they work on here, where it doesn't matter when you adopt them but after a certain amount of time (or sometimes on a date, though I know how that works already) they will grow on their own--like after ten days or so.


PM Rolly-chan. I did, and now I have the codes for all that =D

thenickdude wrote:The code gets run step by step from top to bottom. So you're loading an image, before you allocate a new colour to use with that image, before you use that colour to draw text, before you call imagepng to send the completed picture to the user, before you call imagedestroy to get rid of your image. If you wanted to, for example, draw a filled rectangle of colour behind the text, that would have to happen before the text gets drawn. imagefilledrectangle() could be useful here:

http://nz.php.net/manual/en/function.im ... tangle.php


I'll add those codes in later, it looks pretty easy to figure out XD

thenickdude wrote:"Where you put the codes" is where you want them to be executed, relative to the other instructions you've already got.


I still don't really get it >.<
I could put the codes where the image is displayed on adopt.php, but then when the adopt codes are pasted it won't show, because there's nothing in adopttools.php or simple.php (wherever it should go) that says the writing on it should be displayed. I'm terrible when it comes to these things >.< Always comes up with errors D:
If I put it somewhere in simple.php (or whatever) would it still be the same codes as I have now? Or would I have to change it to something else for it to understand it? D:
    Image-----

    she/they | adult | australia | artist | writer
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    My name is Boo & I am perpetually tired.
    Taking a break from CS for a little while!

    Spotted Tribal count: 31
    ♥︎ Click here to see the hoard! ♥︎
    -
User avatar
qhost
 
Posts: 4352
Joined: Wed Oct 01, 2008 6:36 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Rolly-chan » Mon Feb 16, 2009 12:24 am

I have another question too oO
Everything worked perfectly fine... until yesterday. I just added two adoptables in adoptables.xml and the code didn't work after that. It said:

Code: Select all
Warning: Invalid argument supplied for foreach() in /usr/export/www/vhosts/funnetwork/hosting/fluffyadoptables/bovidae/adopt2.php on line 22

Warning: Invalid argument supplied for foreach() in /usr/export/www/vhosts/funnetwork/hosting/fluffyadoptables/bovidae/adopt2.php on line 32


I checked adoptables.xml over 20 times now and I checked mainpage.php and the other pages too but there doesn't seem to be anything wrong with the links and it works fine for the other adoptables (for the ids 1 to 3 but not for id 7) o_O
I have no idea what I did wrong ?_?

here's the page:
CLICK

EDIT: Oh yeah, and I tried it only with the page, not with the sections and it was working!
Means, it doesn't work if I write "index.php?section=xy&id=x"
but it does work if I write the real path like "adopt.php?id=x"
User avatar
Rolly-chan
 
Posts: 2790
Joined: Tue Nov 18, 2008 8:09 am
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Mausoleum » Mon Feb 16, 2009 1:51 pm

I have a few questions :3 Currently I'm trying out the imagestring code that was given to Kiara, but I'm at a loss as to how to put an image behind :3 I'm dumb...

And also, will there ever be a tutorial as to how to create a new page for an adoptable every time one is adopted? I've been mucking around with various scripts, but I can't find another that doesn't hatch from clicks...

What would really be ideal for me is if they could be added to an account, like a forum account. :3
Image
Kii Project + Lox Recolours + House of Snarkiness + Lackless Deviantart + Art competition = My Stuff.
If you'll excuse me, I'm going to lock myself in the pantry and drown my sorrows in bottled water and granola bars.
"I am an artist, not a printer" Remember that and heck yes, I said it first :U

User avatar
Mausoleum
 
Posts: 3907
Joined: Wed Oct 08, 2008 4:29 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 » Wed Feb 18, 2009 12:21 pm

Rolly-chan wrote:I have another question too oO
Everything worked perfectly fine... until yesterday. I just added two adoptables in adoptables.xml and the code didn't work after that.


It's a mystery to me, could you PM me your adopt2.php and index.php?
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 Nick » Wed Feb 18, 2009 12:22 pm

rosepose wrote:I have a few questions :3 Currently I'm trying out the imagestring code that was given to Kiara, but I'm at a loss as to how to put an image behind :3 I'm dumb...


The code she posted http://www.chickensmoothie.com/Forum/viewtopic.php?f=16&t=5534&start=120#p329267 has a call to createimagefrompng which will load in a background picture before you start doing any drawing.
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 Mausoleum » Wed Feb 18, 2009 2:08 pm

Oh. So does that automatically grab the image, or do I have to put in extra code?
Image
Kii Project + Lox Recolours + House of Snarkiness + Lackless Deviantart + Art competition = My Stuff.
If you'll excuse me, I'm going to lock myself in the pantry and drown my sorrows in bottled water and granola bars.
"I am an artist, not a printer" Remember that and heck yes, I said it first :U

User avatar
Mausoleum
 
Posts: 3907
Joined: Wed Oct 08, 2008 4:29 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 » Wed Feb 18, 2009 6:40 pm

It loads an image that you specify, and then you draw on it with imagetext. Check out the manual on the PHP website for details of the functions involved, it says what they do. http://nz.php.net/manual/en/function.im ... rompng.php
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 quirkitty » Tue Apr 14, 2009 3:24 pm

It's not a bad method. It's one of the simplest I've seen. However, I wouldn't invite the readers to limit themselves to just "copy/pasting" the code. That doesn't help them. It only results in that, when they get errors or something doesn't seem to work properly, they will be 100% clueless, and will always need to rely on someone else to help them figure out what's wrong and fix it.

I have just one thing to critique for the moment: the dates entered for every adoptable. They are specific dates, which means that each new adoptable you want to include in the service will have to be added manually with its own date in the document, eventually leading to a really huge file.
With other systems, you could simply make the user enter some information and click a button to generate a new pet with a unique id into a database, allowing us to dynamically include everything, including the date in which it was created, and even the pet's name. Then, the age calculation would be different. However, I can understand that this is a simple method, and is not intended to go that in depth, or into the concept of databases.

Either way, gotta appreciate your efforts. The script is indented, very easy to read and well commented. That's always good. Thank you. :)
User avatar
quirkitty
 
Posts: 67
Joined: Mon Feb 09, 2009 12:21 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Re: Make your own PHP adoptables system

Postby Nick » Tue Apr 14, 2009 11:06 pm

Arwym, of course you can build a system attached to a database. Such a system would be massively more complex and significantly harder for a beginner to modify, also requiring knowledge about database design and SQL along with a very solid understanding of PHP. This system requires only a shaky knowledge of PHP to modify.

If I wanted to entirely limit people to copying and pasting, I wouldn't have written a tutorial, I just would have provided the zip files from the very end. I hope that by following along the development, they can see what pieces the system is assembled from.
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 quirkitty » Wed Apr 15, 2009 12:55 am

thenickdude wrote:Arwym, of course you can build a system attached to a database. Such a system would be massively more complex and significantly harder for a beginner to modify, also requiring knowledge about database design and SQL along with a very solid understanding of PHP. This system requires only a shaky knowledge of PHP to modify.

If I wanted to entirely limit people to copying and pasting, I wouldn't have written a tutorial, I just would have provided the zip files from the very end. I hope that by following along the development, they can see what pieces the system is assembled from.


Of course you're not entirely limiting people to just copy and paste the script. After all, everything in the script has comments and you did explain many things in the tutorial. You even introduced them to XML. But by only suggesting it, you're already inviting many of them to do so. Because some people just don't want to go through the effort of learning their way around and solving their problems on their own as long as there's someone else out there who can do that in their place.
Some of the users who are trying to jump into this already, expecting everything to work like magic out of the box, didn't even know how to upload the files, and that's really bad. You can't expect to start running when you can't even stand. I'm saying all of this because I made the same mistakes in the past. Anyway, it was just a thought. :) Again, thank you. Also, thank you for responding.

Edit: One last thing-- I am talking about PHP in particular. Not HTML. Although if they don't even know something as elemental as HTML is, I can't imagine how they even think they can successfully manage a PHP-based adoptables system without anyone's help.
Last edited by quirkitty on Wed Apr 15, 2009 5:46 am, edited 1 time in total.
User avatar
quirkitty
 
Posts: 67
Joined: Mon Feb 09, 2009 12:21 pm
My pets
My items
My wishlist
My gallery
My scenes
My dressups
Trade with me

Who is online

Users browsing this forum: No registered users and 1 guest