Jump to content

simple SESSION problem


plodos

Recommended Posts

$sql="SELECT d_name,password FROM doctor WHERE d_name='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched table row must be 1 row
    if($count==1){
	$_SESSION['loggedInD'] = true;
	$_SESSION['UserName'] = $myusername;
	$_SESSION['PassWord'] = $mypassword;
	header('location:doctor.php?'.SID.'');
}

There is a problem

<?
session_start();
include("dbconfig.php");
if (!$_SESSION['loggedInD']) 
{
header("location:login.php"); 
die ();
}
else
{ 
$dd_name=$_SESSION['PassWord'];
$sql = "select d_id from doctor where password like  '%$dd_name%'  ";
echo mysql_query($sql);
echo "\n";
echo $sql;
}

output is like that

Resource id #5 select d_id from doctor where password like '%lukeW%' 

but LUKE ID is 1...

 

$dd_name=$_SESSION['PassWord']; //this is working..

but there is a problem here, $sql = "select d_id from doctor where password like  '%$dd_name%'  ";

im my opinion, we can use the session variables in the SQL querys..

 

What can be the error?

Link to comment
https://forums.phpfreaks.com/topic/108766-simple-session-problem/
Share on other sites

sorry but

i didnt understand the solution way?

 

$dd_name=$_SESSION['PassWord'];
$sql = "select d_name from doctor where password='$dd_name'  ";
$id = mysql_query($sql);
echo $id;

$dd_name=$_SESSION['PassWord'];
$sql = "select d_id from doctor where password='$dd_name'  ";
$id = mysql_query($sql);
echo $id;

if I write like that....Output is only Resource id #4

 

What must I write for see the true result...??

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.