Solved

Search function not working

Posted on 2016-10-05
14
44 Views
Last Modified: 2016-10-21
The search function on the following page isn't working properly: http://www.ssuexed.com/search.php?year=2017&sem=0&ge=C3%2C+*ETH&id=0&cName=&cDept=&tLastName=

For example, if you select the option for GE Type as "C3, *ETH", you will obtain an output that includes "GE C3" as well.

I am attaching the code files - I am thinking that the problem must be in one of these files, i.e., search_subcats.php file, but I am not certain.

I would appreciate any help.
search.php
search_cache.php
search_subcats.php
0
Comment
Question by:geeta_m9
  • 6
  • 6
14 Comments
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41831415
Where is the function showSearchTable defined (line 218 of search.php)

$catalog->showSearchTable($ge, $cName, $cDept, $tLastName);

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41831460
also, where is _cleanVar() function defined? does it include urldecode function
0
 

Author Comment

by:geeta_m9
ID: 41832139
I don't know. I am sending you the rest of the files that I have.
course.php
programs.php
catalog.php
_catalog_defines.php
test.php
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41832216
Nope does not appear to be in any of those.
0
 

Author Comment

by:geeta_m9
ID: 41832250
Ok, I managed to find some more php files which were in an "includes" folder
_catalog_defines-1.php
_stdfunctions.php
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41832330
Not there either.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:geeta_m9
ID: 41832379
0
 

Author Comment

by:geeta_m9
ID: 41832436
I believe the function you are looking for is in catalog_container-1.php
0
 
LVL 52

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41832741
Bingo
This function produces two possible queries
If there is a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM
	courses AS c,
	sections AS s,
	teachers as t,
	tea_sec_rel as tsr 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' AND 
	t.lname LIKE '%Smith%' AND 
	tsr.teacher_id=t.id AND 
	tsr.section_id=s.id 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

If there is not a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM 
	courses AS c, 
	sections AS s 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

Both queries appear to be incapable of producing results with GE C3 - which means we probably need to see the data.
If you can confirm the query by adding the following to the catalog_container-1.php
...
		if ($tLastName) { // or s.year LIKE ('$curYr'+1) // AND s.sem=$this->sem
			$couTea = "AND t.lname LIKE '%$tLastName%' AND tsr.teacher_id=t.id AND tsr.section_id=s.id";
// ADD THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code";

			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code");
		}
		else {
// AND THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code";
			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code");
		}    
...

Open in new window

And then post the query that is dumped from that.
0
 

Author Comment

by:geeta_m9
ID: 41833994
Hi Julian,

I do not have a test server to add the code to the catalog_container-1 program file and run it. If I insert it into the program and upload it, it will be live.

I can, however, run SQL queries against the database and obtain the output. So, if you could give it to me in that format, that would be great.
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41834004
I don't have anything to give you - I want to see what queries the code produces.
0
 

Author Comment

by:geeta_m9
ID: 41854317
Sorry, I forgot to close this question. The problem has been resolved.

Thank you for your help.

Geeta
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41854639
You are welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now