Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2016, 10:33 PM
FounderSim FounderSim is offline
Member
 
Join Date: Sep 2014
Posts: 65
Gender: Male
Credits: 11,355
FounderSim is on a distinguished road
Default

Here's how I debug some mysidia scripting I do. I add DIE's in the code to check on things. I added two DIE statements in your code.

Code:
public function index(){
        $mysidia = Registry::get("mysidia");        
        if($mysidia->input->post("submit")){
            $this->access = "member";
            $this->handleAccess();
            $id = $mysidia->input->post("id");
            if($mysidia->session->fetch("adopt") != 1 or !$id) throw new InvalidIDException("global_id");            
            
            $adopt = new Adoptable($id);
            $cost = $adopt->getCost();
DIE("COST: " . $cost); //delete after seeing result
            $usermoney = $mysidia->db->select("users", array("money"), "username = {$mysidia->user->username}")->fetchColumn();
DIE("MONEY: " . $usermoney); // delete after seeing result
            $newusermoney = $usermoney - $cost;
            $mysidia->db->update("users", array("money" => $newusermoney), "username='{$mysidia->user->username}'"); //this line updates money. I assume $cost is 0 since no subtracting is done.
            $conditions = $adopt->getConditions();
            if(!$conditions->checkConditions()) throw new NoPermissionException("condition");
            
            $name = (!$mysidia->input->post("name"))?"Unnamed":$mysidia->input->post("name");
            $alts = $adopt->getAltStatus();
            $code = $adopt->getCode();
            $gender = $adopt->getGender();
            $mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, 
                                                           "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'notfortrade', "isfrozen" => 'no', "gender" => $gender, "offsprings" => 0, "lastbred" => 0, "originalowner" => $mysidia->user->username, "birthday" => date("F jS, Y")  ));
                        
            $aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
            $this->setField("aid", new Integer($aid));
            $this->setField("name", new String($name));            
            $this->setField("eggImage", new String($adopt->getEggImage()));
            return;
        }
__________________
Reply With Quote
  #2  
Old 01-29-2016, 11:21 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 68,936
Hwona is on a distinguished road
Default

Wait, I found a mistake in the sql syntax... try this:
PHP Code:
public function index(){
        
$mysidia Registry::get("mysidia");        
        if(
$mysidia->input->post("submit")){
            
$this->access "member";
            
$this->handleAccess();
            
$id $mysidia->input->post("id");
            if(
$mysidia->session->fetch("adopt") != or !$id) throw new InvalidIDException("global_id");            
            
            
$adopt = new Adoptable($id);
            
$cost $adopt->getCost();
            
$usermoney $mysidia->db->select("users", array("money"), "username = '{$mysidia->user->username}'")->fetchColumn();
            
$newusermoney $usermoney $cost;
            
$mysidia->db->update("users", array("money" => $newusermoney), "username='{$mysidia->user->username}'");
            
$conditions $adopt->getConditions();
            if(!
$conditions->checkConditions()) throw new NoPermissionException("condition");
            
            
$name = (!$mysidia->input->post("name"))?"Unnamed":$mysidia->input->post("name");
            
$alts $adopt->getAltStatus();
            
$code $adopt->getCode();
            
$gender $adopt->getGender();
            
$mysidia->db->insert("owned_adoptables", array("aid" => NULL"type" => $adopt->getType(), "name" => $name"owner" => $mysidia->user->username"currentlevel" => 0"totalclicks" => 0"code" => $code
                                                           
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'notfortrade'"isfrozen" => 'no'"gender" => $gender"offsprings" => 0"lastbred" => 0"originalowner" => $mysidia->user->username"birthday" => date("F jS, Y")  ));
                        
            
$aid $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
            
$this->setField("aid", new Integer($aid));
            
$this->setField("name", new String($name));            
            
$this->setField("eggImage", new String($adopt->getEggImage())); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:41 PM.

Currently Active Users: 3441 (0 members and 3441 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636