Returns Wrong Defender
Posted: Sat May 10, 2014 4:27 am
				
				I am trying to update a column in a predetermined row. However when i put in any id it returns the wrong defender from the row. For example :
I can't seem to figure out why it's returning empty. Any assistance would be greatly appreciated.
Sincerely,
Aleeious
			If i ask it to resurn the defender of match id 1 it returns blank. I have narrorrowed it down to the bit of code below. I can confirm the statement is executed, binded and fetched so the query is working. I tried to use the query manually in phpmyadmin and the query returns the correct result so it seems to be something with my code.id challenger defender status
1 admin logster897 0
2 pineapplelime admin 0
3 admin testuser 0
Code: Select all
/**
	* get the participants of a match
	* @param $id id of match to check participants for
	*/
    public function getHomeParticipants($id, $status, $username)
    {
        // prepare the sql statement to change the password
        $statement = $this->db->prepare("SELECT defender FROM " . TABLE_MATCHESINDEX . " WHERE id = ? AND status = ? AND challenger = ? LIMIT 1");
        // bing the variables
        $statement->bind_param('iis', $id, $status, $username);
        // if the statement executed successfully
        if ($statement->execute())
        {
            echo "executed<br />";
        	// get the number of results
			$statement->bind_result($defender);
            echo "binded result<br />";
			// fetch all the results
			$statement->fetch();
            echo "fetched<br />";
            // set the defender
            $this->defender[] = $defender;
            echo "Defender = " . $defender . "<br />";
            // so matches were found so return true
        	return true;
		}
        // the query failed so return false
        return false;
    }
Sincerely,
Aleeious