Solved

Search function not working

Posted on 2016-10-05
14
49 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 54

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 54

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 54

Expert Comment

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

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 54

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 54

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 54

Expert Comment

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
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.

772 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