View Full Version : passing recordset content to Session Variable
austinkyo
August 26th, 2009, 10:16 AM
hi Guys,
Can any one tell me the correct way to pass recordset content to Session Variable? i have been try for many times,but still cannnot get it. Here is my script:
<?php
if (!session_id()) session_start();
$_SESSION['Var'] = $row_Var_RS['Var_ID']?>
Thanks
RvGaTe
August 26th, 2009, 10:47 AM
please post your complete code...
austinkyo
August 26th, 2009, 10:56 PM
please post your complete code...
Hi RvGaTe,
Here is the code:
<?php require_once('Connections/db_conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Var_RS = "-1";
if (isset($_SESSION['kt_login_id'])) {
$colname_Var_RS = (get_magic_quotes_gpc()) ? $_SESSION['kt_login_id'] : addslashes($_SESSION['kt_login_id']);
}
mysql_select_db($database_db_conn, $db_conn);
$query_Var_RS = sprintf("SELECT * FROM login_tb WHERE ID = %s", GetSQLValueString($colname_Var_RS, "int"));
$Var_RS = mysql_query($query_Var_RS, $db_conn) or die(mysql_error());
$row_Var_RS = mysql_fetch_assoc($Var_RS);
$totalRows_Var_RS = mysql_num_rows($Var_RS);
?>
<?php
if (!session_id()) session_start();
$_SESSION['User_Email_SV'] = $row_Var_RS['Email']; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="verify-v1" content="c1YO7f6F7gbqyIflhw3/mbQL2K4ImChdWo5K/SwHxJA=" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>Index.php</p>
<p> <?php echo $_SESSION['User_Email_SV']; ?>
</p>
</body>
</html>
<?php
?>
Thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.