Currency for leveling up / Adoptable shop (Fixed again)

Forum
Last Post
Threads / Messages
Status
Not open for further replies.
Just went to buy an adoptable from the shop. I clicked it, it all worked fine 'till I clicked adopt. Then it wouldn't let me adopt, even when I legitimately adopted it. I had to take that part out of adopt.php for it to work. Help?
 
Now that I got the one issue taken care of, I want to submit this information to see if you'd know how to help me convert from adoptables to items.

shop.php code:
PHP:
<?php

// Easy Adoptables Script by Brandon Rusnak
// Get our includes out of the way

include("inc/functions.php");
include("inc/config.php");
include("inc/settings.php");
include("inc/nbbc.php");  // BBCODE Parser
$bbcode = new BBCode;

$stop = 0;

// Connect to our database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!');
mysql_select_db($dbname);


//Set up our login info...
$username = "";
$password = "";

//Check for cookie

if (isset($_COOKIE['adoptu']) and isset($_COOKIE['adoptp'])){

$username = $_COOKIE['adoptu'];
$password = $_COOKIE['adoptp'];

$username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username);
$password = preg_replace("/[^a-zA-Z0-9s]/", "", $password);

//Run login operation
$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

	if($username == $luser and $password == $lpass){
		$isloggedin = "yes";
	}
	else{
	if (isset($_COOKIE['adoptu'])){
	$past = time() - 10; 
	setcookie("adoptu",$username,$past);
	}

	if (isset($_COOKIE['adoptp'])){
	$past = time() - 10; 
	setcookie("adoptp",$password,$past);
	}
	$isloggedin = "no";
	}

}
else
{
//User is not logged in
$isloggedin = "no";

} 


// Define our Template File

$file = $current_theme;



// Get our content for the items page
if($isloggedin == "yes" and $ID == ""){

$article_title = "Market Place";
$article_content = "Shop description goes here.";

$query = "SELECT * FROM items WHERE memberlevel = 'shop'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < $num) {

$iID=@mysql_result($result,$i,"uid");
$name=@mysql_result($result,$i,"name");
$imageurl=@mysql_result($result,$i,"imageurl");
$memberlevel=@mysql_result($result,$i,"memberlevel"); 
$cost=@mysql_result($result,$i,"description");

//Begin our content output...
$article_content=$article_content."<p>".$name."<p><img src='".$imageurl."' /><p>".$cost." <p><a href='buy.php?ID=".$ID."'>Buy ".$name."</a></td>";


$i++;
}

$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);



}
else if ($isloggedin == "no" and $iID == ""){
// Guest is viewing the available items

$article_title = "Shop";
$article_date = date('Y-m-d');
$article_content = "Please log in to buy items.";


$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);

}
else if ($isloggedin == "no" and $aID != ""){
// Guest is trying to adopt an adoptable -- not allowed for tracking purposes

$article_title = "Error";
$article_date = date('Y-m-d');
$article_content = "You must <a href='register.php'>register</a> an account before you can buy adoptables.";

$article_title = stripslashes($article_title);
$article_content = stripslashes($article_content);

}



// Should we show the extra pages in the nav bar?

$link1 = "";
if($show_extra_page1 == "yes"){
$link1 = "<li><a href='$extra_page1_link'>$extra_page1_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}

$link2 = "";
if($show_extra_page2 == "yes"){
$link2 = "<li><a href='$extra_page2_link'>$extra_page2_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; 
}


// Do the template changes and echo the ready template

$template = file_get_contents($file);
$template = replace(':SITETITLE:',$site_title,$template);
$template = replace(':SITENAME:',$site_name,$template);
$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':LINK1:',$link1,$template);
$template = replace(':LINK2:',$link2,$template);
$template = replace(':LINK3:',$link3,$template);

//Get the featured adoptable...
$featured = getfeatured();
$template = replace(':FEATURED:',$featured,$template);

//Ad Management
$header = @file_get_contents("ads/header.txt");
$footer = @file_get_contents("ads/footer.txt");
$tower = @file_get_contents("ads/tower.txt");

$header = stripslashes($header);
$footer = stripslashes($footer);
$tower = stripslashes($tower);

$template = replace(':HEADERAD:',$header,$template);
$template = replace(':FOOTERAD:',$footer,$template);
$template = replace(':TOWERAD:',$tower,$template);


//Is the user logged in?
//$isloggedin = "no";
if ($isloggedin == "yes"){
$template = replace(':WELCOMEORREGISTER:','',$template);
$template = replace(':LOGINORACCT:', '<p>Hi, <a href="profile.php?owner='.$username.'">'.$username.'</a>
<p><a href="logout.php">Log out</a>' ,$template);
}
else{

//User is not logged in
$template = replace(':WELCOMEORREGISTER:','Hi there, please login or register',$template);
$loginform = "<form name='form1' method='post' action='login.php'>
  <p><font size=1>Username 
    <input name='username' type='text' id='username' size=10>
</p>
  <p><font size=1>Password</font>
    <input name='password' type='password' id='password' size=10>
</p>
  <p>
    <input type='submit' name='submit' value='Let`s Go!'>
  </p>
</form>
";
$template = replace(':LOGINORACCT:', $loginform ,$template);
}

echo $template;
?>

MySQL Code
PHP:
CREATE TABLE items VALUES('uid', 'name', 'image', 'shop', 'cost')

So far it only gives a blank page with an error (http://familiarelements.info/shop.php):
Code:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/enddayne/public_html/shop.php on line 88
 
^
Sounds like there's an error here:
PHP:
$iID=@mysql_result($result,$i,"uid");
$name=@mysql_result($result,$i,"name");
$imageurl=@mysql_result($result,$i,"imageurl");
$memberlevel=@mysql_result($result,$i,"memberlevel"); 
$cost=@mysql_result($result,$i,"description");
Ashje said:
Just went to buy an adoptable from the shop. I clicked it, it all worked fine 'till I clicked adopt. Then it wouldn't let me adopt, even when I legitimately adopted it. I had to take that part out of adopt.php for it to work. Help?
 
When I put the anti-theft thingamajig in it gives me an error (I'm still using the Kind column)
 
Don't use the kind column, rose.

Use memberlevel. You are to put shop in memberlevel and make sure all of your free adoptables do in fact say free in their memberlevel for the anti-theft to work.

Ashje said:
Just went to buy an adoptable from the shop. I clicked it, it all worked fine 'till I clicked adopt. Then it wouldn't let me adopt, even when I legitimately adopted it. I had to take that part out of adopt.php for it to work. Help?

It sounds like you are still using the old version of shop.php. Please download shop.php again from my post as well as buy.php and buyconfirm.php if you have not already.
 
The new shop has errors. When I click buy, the page comes up completely blank. Just a white screen.
 
Slight issue: the money portion of the script stops working after a bit. I'll get som, then it won't show that i got some, as well as how much i currently have.
 
Hi! what do you mean by "running queries"? do you mean in the mySQL text document? if so do you think you could make a mod to let me add adopts to the shop directly from the admin part? because my friend controlls the mySQL parts of the site and he's not on a lot
 
Okay, dumb question time..... Are all the fixes discussed in the 8 pages of this thread included in the first post, or do I have to go through and do a bunch of edits? I know, lame question.... it's late.... brain no workee. Humour the crazy lady, 'k?

:p
 
you may want to see if there are any errors the creator of this forum didn't see but once you get past his last post it should be on the first page (i hope)
 
mugwumpr said:
Okay, dumb question time..... Are all the fixes discussed in the 8 pages of this thread included in the first post, or do I have to go through and do a bunch of edits? I know, lame question.... it's late.... brain no workee. Humour the crazy lady, 'k?

:p

There seems to be one rampant issue, which I am trying to fix. Kisazeky isn't responding though.

EDIT:
If you re-install everything on the front page and re-run the queries, it all works fine.
 
Ashje said:
EDIT: If you re-install everything on the front page and re-run the queries, it all works fine.

Excellent, thank you! I'll give that a whirl tomorrow. The brain doesn't work very well after a heavy load of Easter ham....

:rolleyes: ;)
 
OK, seriously. How do I add an adoptable to the shop? And how do I make it so that it says something like this:
"You have earned 20 bucks for leveling up this pet." because it just says: You have earned (number) (currency name) for leveling up this pet.
 
^
Easy.

1 (Adding Adoptables to the shop). Go to MySQL and open the queries. Copy-Paste this:
Code:
INSERT INTO adoptables VALUES ('', 'name','level 0 image','shop','cost')
This is how it works:

'' - Leave this blank

'name' - Replace name with the Adoptable Name but keep the ''.

'level 0 image' - Replace level 0 image with the default image for your adoptable but keep the ''.

'shop' - Leave this as it is.

'cost' - Replace cost with how much the adoptable is going to cost but keep the ''.

Run that query. Now copy-paste this new query into the box:
Code:
INSERT INTO adoptable_rankimages VALUES ('name','1','2','3','4','5','6','7','8')
Again:

'name' - Replace name with the same name you did in the last one. It has to be the same name or your adoptable won't evolve. Keep the ''.

'1' - Replace 1 with the first adoptable image but keep the ''.

and so on and so on. When that is done, run the query and check that your adoptable appears in the shop.

2 (changing Money Message). Go to levelup.php and search for
Code:
$article_content=$article_content. "
			<p>You have earned (number) (currency name) for leveling up this pet.
			<br>You now have  ".$newbalance." (currency name)";
	
			}
Change the "You have earned (number) (currency name) for leveling up this pet, etc."...
 
Hm, well... I don't know how to change the (number) because my users get a random amount from 10-25 "Emeralds". Does the command $money work? Or does anything else so? Maybe I can add something new to the MySQL, like $Money_Get or something, and I do it like this:
$Money_Get = rand(10,25)?
But I seriously don't think that will work.

Can anyone here help me to get the money to show? Please? I enter the code where it should be. And I get THIS error:
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/a8498929/public_html/index.php on line 62"
Or anything similar. How do I solve this?
 
Status
Not open for further replies.

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