Rifts Posted November 12, 2010 Share Posted November 12, 2010 page 1 is this session_start(); include 'db.php'; $email = $_POST['email']; $password = $_POST['password']; $email = stripslashes($email); $password = stripslashes($password); $email = mysql_real_escape_string($email); $password = mysql_real_escape_string($password); $sql="SELECT * FROM directory WHERE email='$email' and password='$password' "; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $wtf="SELECT * FROM directory WHERE email='$email' and password='$password' "; while($row = mysql_fetch_array($wtf)) { $fname = $row['fname']; $lname = $row['lname']; $address = $row['address1']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; } $_SESSION['user'] = $email; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['address1'] = $address; $_SESSION['city'] = $city; $_SESSION['state'] = $state; $_SESSION['zip'] = $zip; $_SESSION['status'] = "1"; page two is just: only the user and status works. session_start(); echo $_SESSION['user'] ; echo $_SESSION['fname'] ; echo $_SESSION['lname'] ; echo $_SESSION['address1']; echo $_SESSION['city'] ; echo $_SESSION['state'] ; echo $_SESSION['zip']; echo $_SESSION['status']; why is that not working Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/ Share on other sites More sharing options...
Minimeallolla Posted November 12, 2010 Share Posted November 12, 2010 theres no input? its all output? Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133484 Share on other sites More sharing options...
Rifts Posted November 12, 2010 Author Share Posted November 12, 2010 there is no output except for the session[user] and session[status] field Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133487 Share on other sites More sharing options...
jdavidbakr Posted November 12, 2010 Share Posted November 12, 2010 So do you know that the query to pull the info is actually pulling a row? Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133489 Share on other sites More sharing options...
Minimeallolla Posted November 12, 2010 Share Posted November 12, 2010 what does the error message say? Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133490 Share on other sites More sharing options...
Rifts Posted November 12, 2010 Author Share Posted November 12, 2010 there is no error also i think i figured it out i needed to add mysql_query Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133491 Share on other sites More sharing options...
ManiacDan Posted November 12, 2010 Share Posted November 12, 2010 Haha, yes, that would do it. You don't actually run the query. Also, a debugging tip: Read your post and your first response. You are saying "here is a script that's designed to store some database data in the session. The only thing being stored is the data from outside the database loop. What is the problem? The problem, clearly, is the database loop. Turn error_reporting all the way up, you would have gotten an error from the mysql_fetch_array line. Echo what you think might be a problem. if you had put an echo inside that loop, you would have known beforehand that it wasn't running. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133493 Share on other sites More sharing options...
Minimeallolla Posted November 12, 2010 Share Posted November 12, 2010 try something like this $session = "$zip <br > $state <br> $city <br> $address <br> $lname <br> $fname <br> "; echo $session that will compress it anyway... lol Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133494 Share on other sites More sharing options...
ManiacDan Posted November 12, 2010 Share Posted November 12, 2010 Minimeallolla is using the wrong variable name and the wrong method for setting multiple data points into a single variable. Your problem is the lack of mysql_query. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133513 Share on other sites More sharing options...
PFMaBiSmAd Posted November 12, 2010 Share Posted November 12, 2010 You are already executing that query once in the code. There's no point in executing it a second time on the same page. Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133514 Share on other sites More sharing options...
ManiacDan Posted November 12, 2010 Share Posted November 12, 2010 Right, get rid of $wtf entirely and use $result. Quote Link to comment https://forums.phpfreaks.com/topic/218499-why-doesnt-this-work-setting-sessions/#findComment-1133518 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.