I am getting the error message "Invalid argument supplied for foreach()". I can't see to figure out what. Below is my query. Is there something I'm missing? Thanks

public function editRole($id) {
        $q = $this->_db->query("SELECT * FROM `" . TP . "roles` WHERE `ID` = '" . floatval($id) . "' LIMIT 1");
        while($r = $q->fetch_array()) {
            $id = $r[0];
        }
        return $id;
    }

Are you sure you are showing the right snippet? If it is the while then the query must have failed. Add some debugging.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.