jefferis Posted June 1, 2012 Share Posted June 1, 2012 Hi folks, I'm new to this board. I am trying to use a session value to call a record to auto fill values for a form page. I defined the variable before the query: $Dealer = $_SESSION['Dealer_ID']; And the query is $query_getAddress = "SELECT * FROM users WHERE users.Dealer_ID = ' $Dealer'"; The user table has field values like UserFirstname, UserAddress, etc. BUT when I put this call on the page : <?php echo $row_getAddress['UserAddress'] . $Dealer ; ?> The $Dealer var prints out correctly, but for some reason, I am not able to echo the other fields in the users table. So it appears the query is not calling the info on the current user/Dealer_ID… from the session ID. I am wondering if there is a problem using session values to get accurate values? Quote Link to comment https://forums.phpfreaks.com/topic/263454-using-session-value-in-query-trouble/ Share on other sites More sharing options...
Pikachu2000 Posted June 1, 2012 Share Posted June 1, 2012 Are you executing the query with mysql_query(), and fetching the data with (for example) mysql_fetch_assoc()? Do you have error reporting set up to display all errors? Quote Link to comment https://forums.phpfreaks.com/topic/263454-using-session-value-in-query-trouble/#findComment-1350186 Share on other sites More sharing options...
jefferis Posted June 1, 2012 Author Share Posted June 1, 2012 THANKS, I figure out what was wrong almost as soon as I posted this question. For some reason the Session value is posting as uppercase, so instead of using = I had to use a LIKE and then everything worked as expected... Thanks again, Jeff Quote Link to comment https://forums.phpfreaks.com/topic/263454-using-session-value-in-query-trouble/#findComment-1350187 Share on other sites More sharing options...
Pikachu2000 Posted June 1, 2012 Share Posted June 1, 2012 You could also use strtolower along with MySQL's LOWER() function to force both to lower case, and effectively make the comparison case insensitive. Quote Link to comment https://forums.phpfreaks.com/topic/263454-using-session-value-in-query-trouble/#findComment-1350188 Share on other sites More sharing options...
fenway Posted June 2, 2012 Share Posted June 2, 2012 If your DB equalities are case-sensitive, that means you're working with a binary collation. Quote Link to comment https://forums.phpfreaks.com/topic/263454-using-session-value-in-query-trouble/#findComment-1350636 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.