Quillink
07-11-2009, 05:41 AM
I've recently constructed my own store and currency system from scratch, with the help from a few tutorials and careful examination of Brandon's script of course. I've gotten as far as the currency, store and store adoption process - heck, everything's working except one tiny simple thing: updating the user's money once s/he buys something!
I even went as far as examining the old easyadopts store mod to see how they did it, then duplicated it, and still nothing? I'm certain it's something simple, perhaps the placement of the code or a missing quotation mark, but here it is:
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."store WHERE id='$id'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"name");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
$clixprice=@mysql_result($result,$i,"clixprice");
$cashprice=@mysql_result($result,$i,"cashprice");
$query2 = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);
$clix=@mysql_result($result2,$i,"clix");
$cash=@mysql_result($result2,$i,"cash");
if($_GET["payclix"])
{ $newclix = $clix - $clixprice;
mysql_query("UPDATE users SET clix = '".$newclix."' WHERE username = '$loggedinname'");
$i++;
echo "clix: $clix balance: $newclix price: $clixprice name: $loggedinname";
}
elseif($_GET["paycash"])
{ $newcash = $cash - $cashprice;
mysql_query("UPDATE users SET cash = '".$newcash."' WHERE username = '$loggedinname'");
$i++;
echo "cash: $cash balance: $newcash price: $cashprice name: $loggedinname";
}
$i++;
}
This is from a duplicated, modified version of 'doadopt.php', and I know the scripting is very nooby, I just picked it up over the past two weeks. Please point out any other problems if you see them! ;)
Unfortunately you won't see it uploaded as a mod for two reasons:
1) It's very Arvyre-specific
2) There are so many small changes to the script I couldn't possibly deconstruct it..! Sorry.
I even went as far as examining the old easyadopts store mod to see how they did it, then duplicated it, and still nothing? I'm certain it's something simple, perhaps the placement of the code or a missing quotation mark, but here it is:
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."store WHERE id='$id'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"name");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
$clixprice=@mysql_result($result,$i,"clixprice");
$cashprice=@mysql_result($result,$i,"cashprice");
$query2 = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);
$clix=@mysql_result($result2,$i,"clix");
$cash=@mysql_result($result2,$i,"cash");
if($_GET["payclix"])
{ $newclix = $clix - $clixprice;
mysql_query("UPDATE users SET clix = '".$newclix."' WHERE username = '$loggedinname'");
$i++;
echo "clix: $clix balance: $newclix price: $clixprice name: $loggedinname";
}
elseif($_GET["paycash"])
{ $newcash = $cash - $cashprice;
mysql_query("UPDATE users SET cash = '".$newcash."' WHERE username = '$loggedinname'");
$i++;
echo "cash: $cash balance: $newcash price: $cashprice name: $loggedinname";
}
$i++;
}
This is from a duplicated, modified version of 'doadopt.php', and I know the scripting is very nooby, I just picked it up over the past two weeks. Please point out any other problems if you see them! ;)
Unfortunately you won't see it uploaded as a mod for two reasons:
1) It's very Arvyre-specific
2) There are so many small changes to the script I couldn't possibly deconstruct it..! Sorry.