PHP session drag

Associate
Joined
19 Oct 2005
Posts
528
Hey folks im trying to drag customer number from the database that is equal to the current session logged in. I have the session working and i have it logged in but the code doesnt seem to work.

Custname is the session variable maybe its a problem with that?

<?php
$CustNumber = $_REQUEST['CustName'];
echo $_REQUEST['CustNumber'];
// Connect to the database.
include("db_connect.php");
// Query the database.
$query = "SELECT CustNumber from Customer WHERE CustName = '$CustNumber'";
$query_result = @mysql_query ($query);
$row = @mysql_fetch_array ($query_result);
if ($row > 1)
{?>
<table border="2" cellpadding="1" cellspacing="1">
<tr><td><b>CustNumber</b></td><td><?php echo $row[CustNumber]?></td></tr>
</table>
<?php
}
else
{
print "That record was not found.\n";
}
?>

Any help would be appreciated thankyou.
 
hmmmmmmmmmmmmmmmmmm

Ok so i made the changes and it didnt work, i think their is a problem with the taking the session name as when i put in the customer name it works, but with the session name it doesnt.

Code:
<?php
$CustNumber = $_SESSION['CustName'];
echo $_SESSION['CustNumber'];
// Connect to the database.
	include("db_connect.php");
// Query the database.
$query = "SELECT CustNumber from Customer WHERE CustName = '$CustNumber'";
$query_result = @mysql_query ($query);
$row = @mysql_fetch_array ($query_result);
if ($row > 1)
	{?>
	<table border="2" cellpadding="1" cellspacing="1">
	<tr><td><b>CustNumber</b></td><td><?php echo $row[CustNumber]?></td></tr>
	</table>
    <?php
	}
else
	{
    print "That record was not found.\n";
    }
	?>

I must not be grabbing the session name correctly?
 
Ripper^ said:
did you try $row > 0 ? because it wont return anything atm. Either that or $row = 1


I tried $row > 1 with find the username if equal to 'dave' and it returned the field i wanted. So i dont see any problem in doing that. I think the problem lies with the session username not being equal to the current user logged in.
Im stumped. :confused:
 
Back
Top Bottom