michael789
asked on
Query by Session Variable
i need to filter my recordset by a session variable that is stored in " $_SESSION['_amember_user'] "
This variable contains entire customer record as array and so also the member ID.
But somehow the code below does not seem to find the specific record for the member ID.
The session variable works fine as I can just use another code like
<?php
session_start();
$user = $_SESSION['_amember_user'] ;
if ($user['member_id'] > 0){
print "Hello $user[name_f] $user[name_l] <br>\n";
} else {
print "You are not logged-in";
}
that works just fine however the query does not!
Any ideas what I am doing wrong? Thank you
This variable contains entire customer record as array and so also the member ID.
But somehow the code below does not seem to find the specific record for the member ID.
The session variable works fine as I can just use another code like
<?php
session_start();
$user = $_SESSION['_amember_user']
if ($user['member_id'] > 0){
print "Hello $user[name_f] $user[name_l] <br>\n";
} else {
print "You are not logged-in";
}
that works just fine however the query does not!
Any ideas what I am doing wrong? Thank you
<?php
session_start();
$member_id = $_SESSION['_amember_user']['member_id'];
$colname_sessionID = "-1";
if (isset($_SESSION['_amember_user']['member_id'])) {
$colname_sessionID = (get_magic_quotes_gpc()) ? $_SESSION['_amember_user']['member_id'] : addslashes($_SESSION['_amember_user']['member_id']);
}
mysql_select_db($database_inburn, $inburn);
$query_sessionID = sprintf("SELECT * FROM amember_members WHERE member_id = %s", GetSQLValueString($colname_sessionID, "int"));
$sessionID = mysql_query($query_sessionID, $inburn) or die(mysql_error());
$row_sessionID = mysql_fetch_assoc($sessionID);
$totalRows_sessionID = mysql_num_rows($sessionID);
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try :
Open in new window