Jump to content


Photo

SQL Glitch


  • Please log in to reply
3 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 03 July 2006 - 02:32 PM

Hi Guys,
Right I have got one minor problem nothing to big or hard but
I just don't understand what I'm doing wrong. On my Login page
I set two sessions:
1. being $_SESION['LoggedIn'] = true;
and 2. being $_SESSION['username'] = $user; ($user being the user field)

Well When i include my Sessions code ie checking if the session
LoggedIn is true, I also have the Username Session. When I use:
echo $username;
or
echo $_SESSION['username'];

It outputs:
Array
???

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 03 July 2006 - 02:53 PM

How are you setting the variables? Somehow you are creating them as arrays. You can view the structure of your arrays with something like...
<?php
echo "<pre>";
print_r($array);
echo "</pre>";
?>


#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 03 July 2006 - 03:02 PM

it's confusing because I didn't create an array...

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 03 July 2006 - 03:22 PM

How is $user being created? Are doing something like thios:
$user = mysql_fetch_array
or
$user = mysql_fetch_row

If you did then mysql_fetch_array and mysql_fetch_row will store the result in an array within the $user variable.

If you want to just store the username then do this:
$user = mysql_fetch_array($result);
$_SESSION['username'] = $user['username'];
$_SESSION['password'] = $user['password'];





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users