Jump to content

Archived

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

xyn

SQL Glitch

Recommended Posts

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:
[code=php:0]echo $username;[/code] or [code=php:0]echo $_SESSION['username'];[/code]

It outputs:
[b]Array[/b]
???

Share this post


Link to post
Share on other sites
How are you setting the variables? Somehow you are creating them as arrays. You can view the structure of your arrays with something like...
[code]<?php
echo "<pre>";
print_r($array);
echo "</pre>";
?>[/code]

Share this post


Link to post
Share on other sites
it's confusing because I didn't create an array...

Share this post


Link to post
Share on other sites
How is $user being created? Are doing something like thios:
[code=php:0]$user = mysql_fetch_array[/code] or [code=php:0]$user = mysql_fetch_row[/code]

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:
[code=php:0]$user = mysql_fetch_array($result);
$_SESSION['username'] = $user['username'];
$_SESSION['password'] = $user['password'];[/code]

Share this post


Link to post
Share on other sites

×

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.