Lodius2000 Posted July 28, 2008 Share Posted July 28, 2008 so here is my new revamped logged-in validation for my cms I replaced if ($_SESSION['username']){ //display page with $valid_user = mysql_query('SELECT username FROM users'); if (in_arry($_SESSION['username'], $valid_user) { //display page now after logging in i get an error WARNING: in_array() [function.in-array]: Wrong datatype for second argument in .......index.php on line 16 i thought haystack had to be an array? my query says get all usernames from table users, so it is an array right? Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/ Share on other sites More sharing options...
DarkWater Posted July 28, 2008 Share Posted July 28, 2008 You never call mysql_fetch_assoc(). Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/#findComment-601201 Share on other sites More sharing options...
Lodius2000 Posted July 28, 2008 Author Share Posted July 28, 2008 sorry darkwater, my bad, i use pear db so i had to adapt my code to look like regular php, but fetch assoc is called via pear, so my actual query is this in pear db $valid_user = $db->query('SELECT username FROM users'); Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/#findComment-601204 Share on other sites More sharing options...
DarkWater Posted July 28, 2008 Share Posted July 28, 2008 I'd appreciate if you gave the real code next time. Do print_r($valid_user); please. Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/#findComment-601205 Share on other sites More sharing options...
Lodius2000 Posted July 28, 2008 Author Share Posted July 28, 2008 I'd appreciate if you gave the real code next time. sorry about the change in code darkwater but I have posted so many things sql related with my peardb code and it takes about 5 replies usually before i get one that says something more than "i dunno what $db->query is." its like everyone zooms in on the object rather than ignore the fact that it is essentially a mysql_query. so i have learned to use regular php functions to get a quick answer when i think there i something wrong with my sql in this case it was not something wrong with the sql it was the class of $db that i was using, i had played with a few before i made this post but had forgotten about $db->getCol, it gets the whole column i print_r it and it says Array ( [0] => ***USER1*** [1] => ***USER2*** ) so i plugged that one into my setup and it works, so solved Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/#findComment-601214 Share on other sites More sharing options...
DarkWater Posted July 28, 2008 Share Posted July 28, 2008 Heh, alright. =P Quote Link to comment https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/#findComment-601216 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.