PDA

View Full Version : Stumped


Fireballchad
11-30-2009, 04:35 AM
lol Right now I am trying to figure out how to do something... but either my server is stupid and keeps breaking or I am way to tired... I think its both. // I cant get it to this for some reason
$newclicks = $totalclicks + $bonus; Its normaly + 1 but it will not accept $bonus for some reason its bugging me... I have the var set correctly from the data base it will show up in the page when i call it but it wont do the clicks :( and earlier i had two $thingone + $thingtwo = $thingthree they where working but they died also...

Arianna
11-30-2009, 09:10 AM
Really? I have code which runs with this:

$newbalance = $money + $wordcount;
From what I see in your code, it should work. Have you made sure that $bonus is being declared?

exdiogene
11-30-2009, 12:57 PM
above it just put
$bonus = 1;

Arianna
11-30-2009, 01:00 PM
Or whatever the bonus is equal to. ;)

Fireballchad
11-30-2009, 05:36 PM
above it just put
$bonus = 1;


I was attempting to ad a feature where you buy and item and it gives you an extra click bonus... I had $bonus become the correct number while querying it from the data base, but it broke the clicks for some reason. When someone clicks it said you did it and logs it but it does not give you the clicks it gives you 0.

Arianna
12-01-2009, 12:11 AM
Make sure that you're getting $bonus correctly - a few weeks ago, I almost totally restructured a piece of code, and then I noticed that it just wasn't getting the most important variable from the database correctly.

exdiogene
12-01-2009, 02:03 AM
above it just put
$bonus = 1;


I was attempting to ad a feature where you buy and item and it gives you an extra click bonus... I had $bonus become the correct number while querying it from the data base, but it broke the clicks for some reason. When someone clicks it said you did it and logs it but it does not give you the clicks it gives you 0.


It would be easier to just put $bonus = 1 if that is what it always is. This puts less strain on the sevrer and increases the speed of the script if it doesnt need to query the database. Have you tried it without using the database?

Arianna
12-01-2009, 09:10 AM
However, what if bonus is different? What would be the point of bonus being one? Then it would just be the same as a normal script. :/

exdiogene
12-01-2009, 12:08 PM
Well in all intents and purposes the script should work as he currently has it.

@Fireballchad: May we look at the script? Maybe we can spot an error as the script should work as you described it.

Fireballchad
12-01-2009, 02:43 PM
Well in all intents and purposes the script should work as he currently has it.

@Fireballchad: May we look at the script? Maybe we can spot an error as the script should work as you described it.


Oh I put it back to normal because I could not get it to work properly.
I will show you what I was attempting to do.
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i = 0;
while ($i < 1) {
$bonus = @mysql_result($result, $i, "bonus");
$i++;
}

$newclicks = $totalclicks + $bonus;// Add 1 click to the current click total of this adoptable...


// Actually insert our click information into the database...

$query = "UPDATE ".$prefix."owned_adoptables SET totalclicks='$newclicks' WHERE aid='$id'";
mysql_query($query);

***Edit
Hmmm I just changed it on my script to see if it could work... and it worked... I have no clue why it was not working before hand...

exdiogene
12-02-2009, 11:42 AM
ok :)

BTW you should change the second "$query" to "$querynew" or something.