Jump to content

[SOLVED] easy 'un, involves in_array()


Lodius2000

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/116910-solved-easy-un-involves-in_array/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.