Solved

Search function not working

Posted on 2016-10-05
14
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
14 Comments
 
LVL 57

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 143

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

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 57

Expert Comment

by:Julian Hansen
ID: 41832330
Not there either.
0
 

Author Comment

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

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 57

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 57

Expert Comment

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

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

695 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