FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 This is the most strange problem i have come accross, i cant see any problems with my code and i have tried everything i can think of to try and fix it but yet the problem still persists here is my sentry.php file <?php class Sentry { var $loggedin = false; var $userdata; function sentry() { session_start(); header("Cache-control: private"); } function logout() { unset($this->userdata); session_destroy(); return true; } function checkLogin($user = '',$pass = '',$group = 10,$goodRedirect = '',$badRedirect = '') { require_once('DBConnector.php'); require_once('Validator.php'); $validate = new Validator(); $connector = new DBConnector(); if($_SESSION['user'] && $_SESSION['pass']) { if(!$validate->validateTextOnly($_SESSION['user'])) { return false; } if(!$validate->validateTextOnly($_SESSION['pass'])) { return false; } $getUser = $connector->Query("SELECT * FROM members WHERE Username='" . $_SESSION['user'] . "' AND Password='" . $_SESSION['pass'] . "' AND Group<='" . $group . "' AND Status=1"); if($connector->GetNumRows($getUser) > 0) { if($goodRedirect != '') { header("Location: ".$goodRedirect."?".strip_tags(session_id())) ; } return true; }else{ $this->logout(); return false; } }else{ if(!$validate->validateTextOnly($user)) { return false; } if(!$validate->validateTextOnly($pass)) { return false; } $getUser = $connector->Query('SELECT * FROM members WHERE Username="$user" AND Password=MD5("$pass") AND Group<="$group" AND Status="1"'); $this->userdata = $connector->GetArray($getUser); if($connector->GetNumRows($getUser) > 0) { $_SESSION["user"] = $user; $_SESSION["pass"] = $this->userdata['Password']; $_SESSION["group"] = $this->userdata['Group']; if ($goodRedirect) { header("Location: ".$goodRedirect."?".strip_tags(session_id())); } return true; }else{ unset($this->userdata); if ($badRedirect) { header("Location: ".$badRedirect); } return false; } } } } ?> the problem is with the query line that is supposed to return the resource id $getUser = $connector->Query('SELECT * FROM members WHERE Username="$user" AND Password=MD5("$pass") AND Group<="$group" AND Status="1"'); it doesnt store or return any value, e.g. if i echo it normally it would say something like Resource #id3, but nothing if i echo it it returns nothing at all, my query is correct i am sure as i have tested it in phpmyadmin by means of sql querying and it returs values then. here are some additional errors that dont make sense other than the fact it is because the query returns nothing that are displayed at the top of the login.php page when you try to login Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in H:\xampp\htdocs\phpcms\includes\DBConnector.php on line 41 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in H:\xampp\htdocs\phpcms\includes\DBConnector.php on line 36 Warning: Cannot modify header information - headers already sent by (output started at H:\xampp\htdocs\phpcms\includes\DBConnector.php:41) in H:\xampp\htdocs\phpcms\includes\Sentry.php on line 79 hope someone can spot anything i have missed coz im stumped on this one p.s. just as a side note if i remove the part that checks the group of the user then the query does return the resource id as it should do which is Resource id #8, but the query returns no results when i know it should do p.s.s. im am wondering if there is a limit or something to the ammount of queries that i can submit to my db swell as the length of them, if there is a memory setting for this in the php.ini file or something then please let me know, i have full controll over my site and all of the settings so im pretty sure i would be able to change things if you explained how i would do them cheers Craig Quote Link to comment https://forums.phpfreaks.com/topic/150547-solved-mysql-query-doesnt-return-anything/ Share on other sites More sharing options...
Mchl Posted March 22, 2009 Share Posted March 22, 2009 Your problem is here. $getUser = $connector->Query('SELECT * FROM members WHERE Username="$user" AND Password=MD5("$pass") AND Group<="$group" AND Status="1"'); You should put the string in double quotes "", because only then variables inside will be evaluated. Quote Link to comment https://forums.phpfreaks.com/topic/150547-solved-mysql-query-doesnt-return-anything/#findComment-790766 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Author Share Posted March 22, 2009 nope thats not the problem i still get the same output and the same errors and the variable still doesnt store the resource id just blank Quote Link to comment https://forums.phpfreaks.com/topic/150547-solved-mysql-query-doesnt-return-anything/#findComment-790778 Share on other sites More sharing options...
Mchl Posted March 22, 2009 Share Posted March 22, 2009 Well then. That's at least one of the problems anyway. Another one is that GROUP is one of MySQL's reserved words. Quote Link to comment https://forums.phpfreaks.com/topic/150547-solved-mysql-query-doesnt-return-anything/#findComment-790786 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Author Share Posted March 22, 2009 fekin HI 5 man thanks a lot for that one, i dont use too many of the mysql commands as i dont need them, i just changed it to UGroup in my db and on the query and it now all works perfectly respect to you and thanks muchly cheers Craig Quote Link to comment https://forums.phpfreaks.com/topic/150547-solved-mysql-query-doesnt-return-anything/#findComment-790814 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.