close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Pass recordset content to Session Variable

Thread began 8/26/2009 7:04 am by austin_kyo371741 | Last modified 8/31/2009 9:00 am by austin_kyo371741 | 8451 views | 6 replies

austin_kyo371741

Originally Said By: Jason Byrnes
  With out seeing this code in context with the rest of the page, it is dificult to say what is wrong.

It looks correct to set the session variable on page load assuming that it occurs after the recordset code.


If you page has a form on it that submits to itself,. the form could be resetting the session variable when it submits. If the Recordset is filtered, the form may not pass the variabel the recordset needs. In this case, the session variable will be set properly when the page loads, but reset to blank when the form submits.  



Hi, Jason
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

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...