![]() |
#1
|
||||
|
||||
![]()
I've been trying to make a stat system for my site, but I can't figure out how to put a random number into an "obedience" column in "owned_adoptables" upon the creation of a pet on the adopt page. Could someone help me? I'm using v.1.3.3
class_ownedadoptables file(tried creating a function on line 43 which is probably completely wrong): PHP Code:
PHP Code:
|
#2
|
||||
|
||||
![]()
Okay a few things I think you are confusing.
1) This: public function setAdoptObedience(){ $query = "INSERT INTO adopts_owned_adoptables (obedience) WHERE aid = $this->aid; VALUES ($obedience)"; $mysidia->db->exec($query); } Use $mysidia->db->insert("table_name_without_prefix",array("name_of _attribute" => $value_of_attribute,"another" => $more_values)) to insert new objects into tables Use $mysidia->db->update("table_name_without_prefix",array("name_of _attribute" => $value_of_attribute,"another" => $more_values),"attribute = $value and anotherattribute = $value") to update values in the table. Your adoptables already exist, you just want to update their information. In OwnedAdoptables you don't create a new OwnedAdptable, you just get or set new information, by selecting something from the database or updating it. 2) To get a random value use rand(min_value,max_value). 3) Your setObedience function returns no value at all, so in adopt.php doing variable = setObedience() doesn't store anything. 4) The new adopt is only added to the database after the line mysidia->db->insert("owned_adoptables",...). Before that line, he's an Adoptable, so the adopt->setObedience() function doesn't exist for an Adoptable, since you created it for an OwnedAdoptable. 5) In fact, in adopt.php the line mysidia->db->insert("owned_adoptables",...) creates the adopt, you can't use a query before the adopt actually existing on the table. You can just get a random variable before the insert and in the insert add the obedience value. Like: PHP Code:
__________________
![]() ![]() ![]() asp.net stole my soul. |
#3
|
||||
|
||||
![]()
Thank you! Everything works, however, I'm getting this weird error upon adoption(free only): Database error 1064 - 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 ' owner='Dream Beauty'' at line 2!
However, the pet still gets adopted. Do you know how to fix this? :3 Otherwise, everything works perfectly and I figured how to do it for bred and shop adoptables - thanks a bunch! Woud this count as mod by any chance? If so, would you mind if I share it? :3 Last edited by Hwona; 06-05-2014 at 09:16 PM. |
![]() |
|
|
What's New? |
What's Hot? |
What's Popular? |