Minase Posted August 28, 2008 Share Posted August 28, 2008 hy there i am working on a new script,but it seem that this query doesnt work quite well .. $buddys = "SELECT * FROM `" . DBPREFIX . "buddys` WHERE `FID` = " . $user->ID . " OR `ID` = " . $user->ID . " AND `Type` = '1'"; i want the query to check if FID = $user->ID OR ID = $user->ID one of them, and Type = 1; thanks Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 28, 2008 Share Posted August 28, 2008 Without parenthesis, AND takes precedence, so your code is actually seeing if: FID = $user->ID OR (ID = $user->ID AND type = 1) So, you need to set off the OR with parentheticals: <?php $buddys = "SELECT * FROM `" . DBPREFIX . "buddys` WHERE (`FID` = " . $user->ID . " OR `ID` = " . $user->ID . ") AND `Type` = '1'"; ?> Quote Link to comment Share on other sites More sharing options...
Minase Posted August 28, 2008 Author Share Posted August 28, 2008 thank you,i did realize after i posted,how it interpret my query this work also $buddys = $db->RecordCount("SELECT * FROM `" . DBPREFIX . "buddys` WHERE `FID` = " . $user->ID . " AND `Type` = '1' OR `ID` = " . $user->ID . " AND `Type` = '1'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.