We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,420 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Invalid Argument

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;
    }
2
Contributors
1
Reply
35 Minutes
Discussion Span
5 Months Ago
Last Updated
3
Views
Question
Answered
joshmac
Junior Poster in Training
84 posts since Apr 2008
Reputation Points: 16
Solved Threads: 5
Skill Endorsements: 0

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

pritaeas
Posting Prodigy
Moderator
9,316 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,467
Skill Endorsements: 86
Question Answered as of 5 Months Ago by pritaeas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0622 seconds using 2.71MB