xyn Posted July 5, 2006 Share Posted July 5, 2006 Hi Guys...I've been setting a user system in sessions which is:$user = $_POST['user'];$_SESSION['LoggedIn'] = true;$_SESSION['username'] = $user;with all the other codes as well. Then I have my sessions code to check int he user is logged in by:$LoggedIn = $_SESSION['LoggedIn'];$usrname = $_SESSION['username'];when I use codes like welcome $usrname I get this:welcome Array.Any ideas how I can get the username session to set the username and then retrieve this? Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/ Share on other sites More sharing options...
mrwhale Posted July 5, 2006 Share Posted July 5, 2006 if its saying array, then thats means you have to write something like$usrname[0] or $usrname[1] instead usually ;) Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53341 Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 What do you get if you try ....[code=php:0]print_r($_SESSION['username']);[/code]? Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53342 Share on other sites More sharing options...
xyn Posted July 5, 2006 Author Share Posted July 5, 2006 using print_r();I get this:Array ( [id] => 1 [user] => xyn [pass] => md5pass [name] => Ash [mail] => ash@eumod.co.uk [date] => 03.07.06 [time] => 11:42am [active] => 1 [news] => 1 [ban] => 0 [pm] => 1 [alert] => 1 ) Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53343 Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 Yep. Its definately an array. $_SESSION['username']['user'] seems to hold your username, but I suspect this isn't what your looking for.Post your code. Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53346 Share on other sites More sharing options...
xyn Posted July 5, 2006 Author Share Posted July 5, 2006 Nope this has only worked when echoing:welcome $username.How would I make the array to place it into an SQL Query,[code=php:0]include "db.php";$result = mysql_query("SELECT * FROM pm WHERE sendto='$_SESSION['username']'");while($data2 = @mysql_fetch_row($result)){$stats = $data2[7];if($stats=="0"){$new="<img src='images/new.jpg'>"; }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53348 Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 [code=php:0]$result = mysql_query("SELECT * FROM pm WHERE sendto='{$_SESSION['username']['user']}");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53350 Share on other sites More sharing options...
xyn Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks, It worked i'll just check to see then i#ll report if any issues where to come up. Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53353 Share on other sites More sharing options...
xyn Posted July 5, 2006 Author Share Posted July 5, 2006 I have one problem:[code=php:0]$query = "UPDATE accounts SET mail='".strtolower($_POST['newemail'])."' WHERE user='".strtolower({$_SESSION['username']['user']})."'" or die(mysql_error());[/code]I get:Parse error: syntax error, unexpected '{', expecting ')' in ./Zone/Account/Reset_email.php on line 172Line 172:[code=php:0]$query = "UPDATE accounts SET mail='".strtolower($_POST['newemail'])."' WHERE user='".strtolower({$_SESSION['username']['user']})."'" or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53359 Share on other sites More sharing options...
Birdman203 Posted July 5, 2006 Share Posted July 5, 2006 Delete the {} around $_SESSION['username']['user'] Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53360 Share on other sites More sharing options...
kenrbnsn Posted July 5, 2006 Share Posted July 5, 2006 Remove the curly braces in that line. They are not needed and are illegal in that context.Ken Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53361 Share on other sites More sharing options...
SharkBait Posted July 5, 2006 Share Posted July 5, 2006 Remove the curley braces from that 2nd strtolower() function. I only use curley braces when the variables is in a string. Here it's in a function Quote Link to comment https://forums.phpfreaks.com/topic/13736-mysql_fetch_arraysql-problems/#findComment-53363 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.