Page 4 of 4

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:12 pm
by timoteo
"16"

genius. Now how do I get this to work as a session on my page?

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:18 pm
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'];
}

?>

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:26 pm
by timoteo
"16"

we're going strong!!!

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:28 pm
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

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:32 pm
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:

Re: help with sessions please

Posted: Wed Jan 12, 2011 4:38 pm
by Neilos
Persistence is key, lol.

Re: help with sessions please

Posted: Wed Jan 12, 2011 5:28 pm
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