New Rats Not Showing Up?

Forum
Last Post
Threads / Messages

AlexC

Moderator
Moderator
Joined
Dec 17, 2009
Messages
742
Points
0
Age
28
Location
Canada
Mysidian Dollar
43,036
Okay, so I've started working on my rat site again. I upgraded my site (and made the accidental mistake of not saving my chances) but now I've come across a problem.

New rats are not showing up. I bred - no rat. I gave myself rats through the ACP - no rats. I bought from the adoption center - "this ID does not exist".

What? I have no idea what's happening - did I break something?

And on a side note... is it possible for me to go back and edit my Adoptable Class for already made rats? I really wish we could edit more things in the edit adoptable page.
 
Can you access your database via PHPMyAdmin or another similar platform? It sounds like there is a mismatch in you database versus the site coding and I'd bet looking at the database would reveal the issue.
 
I can get in, but I'm not sure what to look for? Can you tell me what to look for?
 
I'm not sure either but if the ID doesn't exist I'd start in the prefix_adoptables table. If it looks normal, take a screenshot and post it here and maybe we can find the problem?
 
despite common belief, rats do not escape often. they prefer to stay near their parents. *owns two personally, five overall*
 
that's different then escaping. wanting to come out for attention, as appose to disappearing into the walls like hamsters.

i still can't figure out what the problem is.
 
Code:
<?php

include("inc/functions.php");

//***************//
//  START SCRIPT //
//***************//

$id = $_GET["id"];
$promocode = $_GET["promocode"];
$name = $_GET["name"];

if($isloggedin == "yes"){
	if($_SESSION["allow"] != 1){
	
		$article_title = $err_idnoexist;
		$article_content = $err_idnoexist_text;
	}
	elseif($_SESSION["allow"] == 1){
	
		// I guess the first thing to do is see if we have a valid adoptable ID submitted...
		if($id == "" or !is_numeric($id)){
			$article_title = $err_idnoexist;
			$article_content = $err_idnoexist_text;
		}
		else{
			// The adoptable ID appears to be valid, so we need to double check that it is valid by pulling up the adoptable in the DB

			$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id'";
			$result = runquery($query);

			//$result = runquery($query); HoF, this should be removed.
			$row = mysql_fetch_array($result);

			$aid = $row['id'];
			$type=$row['type'];
			$description=$row['description'];
			$eggimage=$row['eggimage'];

			if($id == $aid){
				// The ID submitted matches an existing adoptable type
				$canadopt = canadopt($aid, "adopting", $promocode, $row);

				// If we can adopt this creature, do the adoption
				if($canadopt == "yes") {
					if (changecash(-$row['cost'], $GLOBALS['loggedinname'], $GLOBALS['money'])==true) {				
						// BEGIN the actual adoption process

						// First we see if we have a custom name; if not, we use the default name
						if($name == ""){
							$name = $type;
						}

						// Now we determine if we are using alternate images or not

						$alts = getaltstatus($id, 0, 0);

						// We need a unique code for the adoptable so we can show it to the user when we're done here...

						$code = rand(1, 20000);
						$genders = array('f', 'm');
						$rand = rand(0,1);
						
						runquery("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0')");

						// Adoption complete, show the user a confirmation screen...

						$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE code='$code' and owner='$loggedinname'";
						$result = runquery($query);
						$num = mysql_numrows($result);
						 
						$id=@mysql_result($result,0,"aid"); 

						$article_title = $name." adopted successfully";
						$article_content = "<img src='".$eggimage."'><br>".$congrats1." ".$name.".  You can now manage ".$name." on the 
						<a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=".$id."'>Click Here to Manage ".$name."</a><br>
						<a href='myadopts.php?act=bbcode&id=".$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a></b><br><br>
						Be sure and <a href='levelup.php?id=".$id."'>feed</a> ".$name." with clicks so that they grow!";
						unset($_SESSION["allow"]);
						// END the actual adoption process
					}
					else {
						$article_title = "Not enough money.";
						$article_content = "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable. Earn some money and then try again.";
					}
				}
				else {
					$article_title = $accden;
					$article_content = $adoptnoper;
				}
			} // End the if for if $id == $aid
			else {
				// Adoptable does not exist, show an error.

				$article_title = $err_idnoexist;
				$article_content = $err_idnoexist_text;
			} // End the else for if $id == $aid
		} // End the valid ID input else test statement (bulk of code goes above here)
	}
} // End the log in check IF
else {
	// Guests cannot adopt pets, so why bother...
	$article_title = $guesttitleerror;
	$article_content = $guesterror;
} // End the log in check ELSE 

//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>

Here you go.
 
Okay looking at the code there are two possible ways you could be getting the error.

PHP:
		if($id == "" or !is_numeric($id)){
			$article_title = $err_idnoexist;
			$article_content = $err_idnoexist_text;
		}

PHP:
			else {
				// Adoptable does not exist, show an error.

				$article_title = $err_idnoexist;
				$article_content = $err_idnoexist_text;
			} // End the else for if $id == $aid

(Quite frankly the second one is VERY redundant but oh well)

As far as the code goes, the second issue would be caused by a bad mysql statement, but it looks as though it would work just fine and I'm assuming other mysql statements on your site are working...?

If the case is the first one causing the problem, it would mean the $_GET($id) is not working properly and you'd have to post the adopt.php code for me to see if there's an error though. (sorry troubleshooting can be annoying)
 
Code:
<?php

include("inc/functions.php");

//***************//
//  START SCRIPT //
//***************//

$id = $_GET["id"];
$promocode = $_GET["promocode"];
$_SESSION["allow"] = 1;
// Here we check if we have an ID that has been submitted or no

if($id == "" or !is_numeric($id)) {
	// We did not enter in an id, or it is not a number
	$article_title = $showingtitle;
	$article_content = $showing;

	// If we are a guest, show a message that lets them know that they cannot adopt...
	if($isloggedin != "yes"){
		$article_content = $article_content.$showingguest;
	}

	// Begin the output of all the adoptables to the user...
	$query = "SELECT * FROM ".$prefix."adoptables";
	$result = runquery($query);
	
	$article_content .= "<form name='form1' method='get' action='doadopt.php'>
	<h3>Available Adoptables</h3><table>";

	while($row = mysql_fetch_array($result)) {
		$aid=$row['id']; //The adoptable's ID
		$type=$row['type'];
		$description=$row['description'];
		$eggimage=$row['eggimage'];

		// Call a function to check if we have the proper privledge level to adopt this pet
		if($promocode == ""){
			$promocode = "none";
		}

		$canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...

		if($canadopt == "yes"){
			//If we can adopt the adoptable, show the image and adoption link...
			$article_content .= "<tr>
			<td><input type='radio' name='id' id='id' value='{$aid}' /></td>
			<td style='text-align: center'><img src='".$eggimage."' /></td>
			<td><strong>{$type}</strong> - {$row['cost']} {$GLOBALS['settings']['cost']}.<br />{$description}</td></tr>";
		}
	} // End the looping out of all adoptables...
	
	$article_content .= "</table>
	<h3>Adopt</h3>
			  <p>Adoptable Name: <input name='name' type='text' id='name' />
				<input name='promocode' type='hidden' id='promocode' value='".$promocode."'>
			  </p>
			  <p>
				<input type='submit' name='Submit' value='Adopt Me'>
			</p>
	</form>";
} // This bracket ends the IF check for whether or not an ID was entered
else{
	// We have specified an ID of an adoptable we wish to adopt

	$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id' LIMIT 1";
	$result = runquery($query);
	$row = mysql_fetch_array($result);

	$aid = $row['id'];
	$type=$row['type'];
	$description=$row['description'];
	$eggimage=$row['eggimage'];

	if($aid == $id){
		//The adoptable exists and is valid

		$canadopt = canadopt($aid, "adopting", $promocode, $row); 

		if($canadopt == "yes"){

			$article_title = "Adopting ".$type;
			$article_content = $langa1."".$type.$langa2;

			$article_content = $article_content."<br><img src='".$eggimage."' border='0'><br>
			<form name='form1' method='get' action='doadopt.php'>
			  <p>Adoptable Name: 
				<input name='name' type='text' id='name'>
				<input name='id' type='hidden' id='id' value='".$id."'>
				<input name='promocode' type='hidden' id='promocode' value='".$promocode."'>
			  </p>
			  <p>
				<input type='submit' name='Submit' value='Adopt Me'>
			</p>
			</form>";
		}
		else{
			$article_title = $accden;
			$article_content = $adoptnoper;
		} // End Can Adopt ELSE
	}
	else {
		//The adoptable does not exist, nothing we can do...
		$article_title = $err_idnoexist;
		$article_content = $err_idnoexist_text;
	} // End adoptable does not exist ELSE
} // This bracket ends the else statements for whether or not an ID was entered


//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>

here is the adopt.php. man, troubleshooting is very hard.
 
*sigh* I can't find anything wrong. One last thing I can think of is can you take a screen shot of all the fields in your owned_adoptables table?
 
I can do that tomorrow, but I have to get off to make emergency rat cages. I'll do it then.
 
Okay yeah I found the problem.

Replace the ENTIRE doadopt.php page with this code:
PHP:
<?php

include("inc/functions.php");

//***************//
//  START SCRIPT //
//***************//

$id = $_GET["id"];
$promocode = $_GET["promocode"];
$name = $_GET["name"];

if($isloggedin == "yes"){
	if($_SESSION["allow"] != 1){
	
		$article_title = $err_idnoexist;
		$article_content = $err_idnoexist_text;
	}
	elseif($_SESSION["allow"] == 1){
	
		// I guess the first thing to do is see if we have a valid adoptable ID submitted...
		if($id == "" or !is_numeric($id)){
			$article_title = $err_idnoexist;
			$article_content = $err_idnoexist_text;
		}
		else{
			// The adoptable ID appears to be valid, so we need to double check that it is valid by pulling up the adoptable in the DB

			$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id'";
			$result = runquery($query);

			//$result = runquery($query); HoF, this should be removed.
			$row = mysql_fetch_array($result);

			$aid = $row['id'];
			$type=$row['type'];
			$description=$row['description'];
			$eggimage=$row['eggimage'];

			if($id == $aid){
				// The ID submitted matches an existing adoptable type
				$canadopt = canadopt($aid, "adopting", $promocode, $row);

				// If we can adopt this creature, do the adoption
				if($canadopt == "yes") {
					if (changecash(-$row['cost'], $GLOBALS['loggedinname'], $GLOBALS['money'])==true) {				
						// BEGIN the actual adoption process

						// First we see if we have a custom name; if not, we use the default name
						if($name == ""){
							$name = $type;
						}

						// Now we determine if we are using alternate images or not

						$alts = getaltstatus($id, 0, 0);

						// We need a unique code for the adoptable so we can show it to the user when we're done here...

						$code = rand(1, 20000);
						$genders = array('f', 'm');
						$rand = rand(0,1);
						
						runquery("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0','Happy')");

						// Adoption complete, show the user a confirmation screen...

						$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE code='$code' and owner='$loggedinname'";
						$result = runquery($query);
						$num = mysql_numrows($result);
						 
						$id=@mysql_result($result,0,"aid"); 

						$article_title = $name." adopted successfully";
						$article_content = "<img src='".$eggimage."'><br>".$congrats1." ".$name.".  You can now manage ".$name." on the 
						<a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=".$id."'>Click Here to Manage ".$name."</a><br>
						<a href='myadopts.php?act=bbcode&id=".$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a></b><br><br>
						Be sure and <a href='levelup.php?id=".$id."'>feed</a> ".$name." with clicks so that they grow!";
						unset($_SESSION["allow"]);
						// END the actual adoption process
					}
					else {
						$article_title = "Not enough money.";
						$article_content = "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable. Earn some money and then try again.";
					}
				}
				else {
					$article_title = $accden;
					$article_content = $adoptnoper;
				}
			} // End the if for if $id == $aid
			else {
				// Adoptable does not exist, show an error.

				$article_title = $err_idnoexist;
				$article_content = $err_idnoexist_text;
			} // End the else for if $id == $aid
		} // End the valid ID input else test statement (bulk of code goes above here)
	}
} // End the log in check IF
else {
	// Guests cannot adopt pets, so why bother...
	$article_title = $guesttitleerror;
	$article_content = $guesterror;
} // End the log in check ELSE 

//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>

The problem was with the mood modification, but this code will work now.
 
Thank you very much! I shall change that as soon as possible.
 
I am unable to add new rats to my site. I don't know why. Adoption is fine, the rest is not. What can I do? D:
 
You can use the same fix on all the codes that include adding new rats. nadopt.php is one I know of and there may be a few others in the admin.php but I can't recall.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top