Can someone please help me understand why I cannot query the database using a session variable? The code below will work properly if I change the $logname to a value that I know exist in the database, but when using the session variable $logname,,, it does not appear to work. The session variable $logname is set and I can see it on the echo command on the 4th line below. I must be missing something or not understanding how the sessions work. Please help!
<?php
session_start();
include("rcubed.inc"
;
echo $logname;
$connection= mysql_connect($host, $user, $password) or die ("Couldn't connect to server"
;
$db = mysql_select_db($database, $connection) or die ("Couldn't select database"
;
function build_dropdown() {
$sql = "select customer_id from customer where loginname='$logname'";
$result=mysql_query($sql) or die (mysql_error()." - ".mysql_errno());
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
extract($row);
$output .= "<OPTION VALUE=$customer_id>$customer_id</OPTION>";
}
return $output;
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Example form using JavaScript to change information</title>
</head>
<body>
<form name="globe" method="POST" action="test_submit_rma.php">
<p align="center"></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">Ship to State</p>
<p></p>
<p align="center"><select name="scountry">
<?php echo build_dropdown() ?>
</select>
</form>
</body>
</html>
<?php
session_start();
include("rcubed.inc"

echo $logname;
$connection= mysql_connect($host, $user, $password) or die ("Couldn't connect to server"

$db = mysql_select_db($database, $connection) or die ("Couldn't select database"

function build_dropdown() {
$sql = "select customer_id from customer where loginname='$logname'";
$result=mysql_query($sql) or die (mysql_error()." - ".mysql_errno());
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
extract($row);
$output .= "<OPTION VALUE=$customer_id>$customer_id</OPTION>";
}
return $output;
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Example form using JavaScript to change information</title>
</head>
<body>
<form name="globe" method="POST" action="test_submit_rma.php">
<p align="center"></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">Ship to State</p>
<p></p>
<p align="center"><select name="scountry">
<?php echo build_dropdown() ?>
</select>
</form>
</body>
</html>