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
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...??

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.