guyfromfl Posted May 13, 2007 Share Posted May 13, 2007 For some reason the result keeps comming up null. All the echos are there to see if the values are there at certain points and ill take out once it works... The checkClockIn function is called from another file but I know its ok because $emp has a value so i know i declared the class in the other file correctly. <?php public function checkClockIn($emp, $pin) { $sql = "SELECT PIN FROM tblEmployees WHERE empId='$emp'"; $pof = $this->dbQuery($sql); echo $pof; if ($pin == $pof) { return true; } else { return false; } public function dbQuery($query) { $result = mysql_query($query); $row = mysql_fetch_array($result); $answer = $row[0]; echo $row; return $answer; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/ Share on other sites More sharing options...
marmite Posted May 13, 2007 Share Posted May 13, 2007 Is this all the code? Which variable / function is returning null? What do the echos return? Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252244 Share on other sites More sharing options...
marmite Posted May 13, 2007 Share Posted May 13, 2007 I might be wrong, but are you missing a } ? Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252246 Share on other sites More sharing options...
guyfromfl Posted May 13, 2007 Author Share Posted May 13, 2007 I have a file /includes/dblib.php that contains about 2 dozen functions for querys to the database but i thought putting all that on here would annoy people $pof is the value of the employee's pin number in the database and $pin is the number the employee entered in the login form. $emp has its value but $pof (the result from the db) is null so all the echos dont return anything at all. Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252252 Share on other sites More sharing options...
guyfromfl Posted May 13, 2007 Author Share Posted May 13, 2007 yea i missed the last } in checkClockIn when i was hightlighting Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252256 Share on other sites More sharing options...
Barand Posted May 13, 2007 Share Posted May 13, 2007 Try checking for errors when you call mysql_query. $result = mysql_query($query) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252267 Share on other sites More sharing options...
guyfromfl Posted May 13, 2007 Author Share Posted May 13, 2007 mysql_error = Access denied for user 'apache'@'localhost' (using password: NO) which is weird because there are about four queries that work fine before it gets to checkClockIn. strange..ill try google for this one Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252272 Share on other sites More sharing options...
marf Posted May 13, 2007 Share Posted May 13, 2007 One thing I like to do is change $sql = "SELECT PIN FROM tblEmployees WHERE empId='$emp'"; to $sql = "SELECT PIN FROM tblEmployees WHERE empId='".$emp."'"; I'm not sure if that's better, or if it's even your problem Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252288 Share on other sites More sharing options...
guyfromfl Posted May 13, 2007 Author Share Posted May 13, 2007 yea that makes no difference... is there an instance where putting the variables outside the query ""'s would change the output? Quote Link to comment https://forums.phpfreaks.com/topic/51218-classmysql-query-problem/#findComment-252303 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.