Kyle123 Posted December 28, 2011 Share Posted December 28, 2011 Okay I need some help. I want to check a MySQL DB and then if it says 0 then don't do anything if it says anything else echo out what's there. I have tried for about a hour now. Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/ Share on other sites More sharing options...
ignace Posted December 28, 2011 Share Posted December 28, 2011 Please post your code. Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/#findComment-1301841 Share on other sites More sharing options...
Kyle123 Posted December 28, 2011 Author Share Posted December 28, 2011 <? include("config.php"); if(isset($_GET['username']) and ($_GET['password']) and ($_GET['hwid'])){ $username = $_GET['username']; $password = md5($_GET['password']); $query=mysql_query("SELECT banned FROM `members` WHERE `login`='$username'"); $result = mysql_num_rows($query); $outcome = ($result > 0) ? 'true' : 'false'; echo $outcome; } ?> I think the last bit is all wrong. Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/#findComment-1301844 Share on other sites More sharing options...
ignace Posted December 28, 2011 Share Posted December 28, 2011 Try this: include("config.php"); if(isset($_GET['username']) and ($_GET['password']) and ($_GET['hwid'])){ $username = $_GET['username']; $password = md5($_GET['password']); $sql = "SELECT banned FROM `members` WHERE `login`='$username'"; $query=mysql_query($sql) or exit("ERROR: " . mysql_error() . "<br>QUERY: " . $sql); $result = mysql_num_rows($query); $outcome = ($result > 0) ? 'true' : 'false'; echo $outcome; } Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/#findComment-1301847 Share on other sites More sharing options...
Kyle123 Posted December 28, 2011 Author Share Posted December 28, 2011 Okay I have done it now. Noob way but it works. $query = mysql_query("SELECT * FROM `members` WHERE login='$username'"); while($row = mysql_fetch_array($query)){ if($row['banned']=="0"){ }else{ echo $row['banned']; die(); } } Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/#findComment-1301852 Share on other sites More sharing options...
Maq Posted December 28, 2011 Share Posted December 28, 2011 Kyle, in the future, please place OR tags around your code. You also should not be using short tags, use <?php. Quote Link to comment https://forums.phpfreaks.com/topic/253947-checking-mysql-db/#findComment-1301873 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.