$Dep = "select departmentName from department where userid='$Userid' ";
Most likely the column userid would be an int or bigint. In that case you shouldn't enclose its value in quotes.
So it should rather be .... where userid=$Userid
I can see the same possible error in second sql command as well
where registrationNo='$RegNo' AND department= $Dep
should be where registrationNo=$RegNo AND department= '$Dep'
ckchaudhary
Junior Poster in Training
79 posts since Oct 2011
Reputation Points: 15
Solved Threads: 17
Skill Endorsements: 2
You're using a sub-query for the department. It needs to be wrapped in brackets. E.g.
$query = "select registrationNo,name,fatherName,cnic,gender,discipline,department,admissionSession,email,password,address,domicile,contactNo,status,currentEmployer,designation,salaryInfo,totalExperience,lastOrganizationname,organizationAdd,organizationPhno,organizationEmail,Remarks from students where registrationNo='$RegNo' AND department = ($Dep)";
Alternatively, you could write the query using a join, thus avoiding the need for a sub-query entirely.
blocblue
Practically a Posting Shark
837 posts since Jan 2008
Reputation Points: 272
Solved Threads: 161
Skill Endorsements: 12
SELECT `s`.*
FROM `students` `s`
INNER JOIN `department` `d` ON (`d`.`departmentName` = `s`.`department` AND `d`.`userid` = '{$Userid}')
WHERE `s`.`registrationNo` = '{$RegNo}'
blocblue
Practically a Posting Shark
837 posts since Jan 2008
Reputation Points: 272
Solved Threads: 161
Skill Endorsements: 12
I owe you?
Please mark as solved.
blocblue
Practically a Posting Shark
837 posts since Jan 2008
Reputation Points: 272
Solved Threads: 161
Skill Endorsements: 12
Question Answered as of 8 Months Ago by
blocblue,
jstfsklh211
and
ckchaudhary