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 » Wed Aug 25, 2010 2:12 pm

Nick wrote:Did you remember to comment out the "header('Content-Type ..." line as I instructed? If you leave that line in, your browser will try to interpret the error message as an image instead of showing it as text.

The error I got printed (after saving the image and opening it in notepad):

Table 'a3459659_122195.adoptables' doesn't exist

What tables have you created in your database?


Oh, I missed that.

Now I have changed it.

I did create a table in my database, and its number was a3459659_122195. It is called adoptables as well, although it starts with a capital "A". Would that make a difference, and where would I change that?

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 Nick » Wed Aug 25, 2010 5:07 pm

Yep, the names are case-sensitive. Either rename your table in your database, or change all the places in the code where you are SELECTing FROM adoptables or INSERTing INTO adoptables to use the capital letter.
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 Aug 26, 2010 3:11 am

Okay, so I made a whole new table, with everything the same, except for making "adptables" lowercase.

It must be getting somewhere, because the pets are finally showing up, but they are showing as white boxes with a red "x" in them:

Image

I noticed something, though. When I get the code after I adopt, this is the code for the Forum:

Code: Select all
[url=http://laughingwolflane.comze.com/][img]http://laughingwolflane.comze.com//simple.php?idp=0&.jpg[/img][/url]
                Owner's name: Sarah
                Pet's name: Test
                Adopted on: 2010-08-25


It says that idp=0&.jpg

Usually it's a long number after that, and all of my file names for pets on that site are .png, not .jpg . Does this have anything to do with it?
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 Aug 26, 2010 2:43 pm

Again, comment out the "header('Content-type:" line, and go to the image's address in your browser directly, so you can actually read the error message. Unless you can read the error message, you aren't going to get anywhere.

I would also suggest adding error checking in adopt.php:

Code: Select all
$result1 = mysql_query($sql);

Becomes:

Code: Select all
$result1 = mysql_query($sql) or die(mysql_error());

Add that sort of error checking to every place you call mysql_query, it'll then be able to tell you exactly when an error occurs.
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 Aug 27, 2010 3:43 pm

Alright, first of all I wanted to say sorry for making this a lot more difficult than it needs to be.

So I changed the two things, and when I adopt, the message that comes up is:

"Adoptables
Duplicate entry '0' for key 1".
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 Aug 27, 2010 7:56 pm

You need to change your primary key column on your adoptables table to add the "auto increment" attribute - that makes it so that the ID numbers of your pets are generated automatically in increasing order. Are you using phpMyAdmin to make your database changes? Go to the structure of your adoptables table, and click the pencil icon next to your primary column. In the page that appears, tick the "AUTO_INCREMENT" box and click save.
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 » Sat Aug 28, 2010 1:52 am

Nick wrote:You need to change your primary key column on your adoptables table to add the "auto increment" attribute - that makes it so that the ID numbers of your pets are generated automatically in increasing order. Are you using phpMyAdmin to make your database changes? Go to the structure of your adoptables table, and click the pencil icon next to your primary column. In the page that appears, tick the "AUTO_INCREMENT" box and click save.


Alright, I added the "auto increment", and now I get this message when I view the pet:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
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 » Sat Aug 28, 2010 2:16 pm

Your adopt.php reads a value from a variable which does not exist, "$adopt". Change this line:

Code: Select all
$sql = "INSERT INTO Adoptables (date,petID,varID,owner) VALUE (NOW(),'$adopt','$v_id','$adopter')";

To:

Code: Select all
$sql = "INSERT INTO Adoptables (date,petID,varID,owner) VALUE (NOW(),".$adoptable['id'].",'$v_id','$adopter')";
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 » Sat Aug 28, 2010 2:35 pm

Okay, I changed that, but this error message still comes up:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
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 » Sat Aug 28, 2010 2:44 pm

You must be viewing a pet that was already adopted. Adopt a new one. All the species work for me now, you just need to un-comment the header('Content-Type... line and the image should appear too.
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

Who is online

Users browsing this forum: No registered users and 4 guests