Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.