help with sessions please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: help with sessions please

Post by timoteo »

"16"

genius. Now how do I get this to work as a session on my page?
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: help with sessions please

Post by Neilos »

Phew, thank the lord, we have found the problem!!!!! lol. Ok so the problem was with the connection to the database. You weren't selecting the database. This whole time I thought that you were doing this in Connections/recommendingpeople.php as the name sort of implies lmao!

Ok so what you will want to do is;

Code: Select all

<?php
require_once('Connections/recommendingpeople.php');

session_start();

// I have put this equal to 'french' I assume that this is a valid username in rsusername, if not please change!
$username = "french";

mysql_select_db($database_recommendingpeople, $recommendingpeople);

$query = "SELECT * FROM username WHERE username='$username';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if (!$result) {
echo "Got nothing";
} else {

$_SESSION['userid'] = $row['userid'];

echo $_SESSION['userid'];
}

?>
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: help with sessions please

Post by timoteo »

"16"

we're going strong!!!
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: help with sessions please

Post by Neilos »

lol that's it, you're echoing the session variable. 16 is saved into the session for your use on all other pages!!! :D
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: help with sessions please

Post by timoteo »

Thats awesome. Your great. How can I thank you?
I think I am going to have to recompose my original page with the problem and see how it goes. :drunk:
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: help with sessions please

Post by Neilos »

Persistence is key, lol.
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: help with sessions please

Post by timoteo »

This aspect of my page is working ggrrreat now. Thankyou for all you've done for me Nielos. You're the best. I owe you one. May you have the best of luck in your life. cheers.
I think what I need to be more careful of is randomly pressing buttons in dreamweaver without understanding what they do. My php was a mess with what dreamweaver wrote me. I'm learning...
till next time.... :D
Post Reply