PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Program Error Using PHP Include

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Program Error Using PHP Include

    Hello,

    I have a CGI version of Zoom implemented and am including the search.cgi file using this php:

    Code:
    <?php
        $QSTRING = $_SERVER&#91;'QUERY_STRING'&#93;; 
        while &#40;list &#40;$header, $value&#41; = each &#40;$HTTP_GET_VARS&#41;&#41; 
        &#123; 
        $QSTRING = $QSTRING.'&'.$header.'='.$value; 
        &#125;
        virtual&#40;"/cgi-bin/search.cgi".'?'.$QSTRING&#41;;
      ?>
    The problem arises when I do an exact search using quotes "" that returns no results. I get the following error:

    Warning: virtual() [function.virtual]: Unable to include '/cgi-bin/search.cgi?zoom_query=%22brand+guide%22&zoom_per_p age=10&zoom_and=1&zoom_sort=0&zoom_query=\"brand guide\"&zoom_per_page=10&zoom_and=1&zoom_sort=0' - request execution failed in d:\server2go\htdocs\zsearch.php on line 38
    I also get an error message that pops up in IE saying:
    search.cgi.exe has generated errors and will be closed by Windows. You will need to restart the program.

    An error log is being created.
    Can you help me figure out what code to add so that it simply says there aren't any results?

    If there are no results in normal search it says no results, and exact searches with matches work fine.

  • #2
    Re: Program Error Using PHP Include

    Originally posted by Matt
    Warning: virtual() [function.virtual]: Unable to include '/cgi-bin/search.cgi?zoom_query=%22brand+guide%22&zoom_per_p age=10&zoom_and=1&zoom_sort=0&zoom_query=\"brand guide\"&zoom_per_page=10&zoom_and=1&zoom_sort=0' - request execution failed in d:\server2go\htdocs\zsearch.php on line 38
    There's something wrong here with the URL that's been passed to the CGI. The section I've highlighted in bold above should not be there. Did you define your own search form for the query to be entered into? It seems like it is doubling up on the parameters, and failing to escape the double quote characters in the query correctly. This is most likely the cause of the problem.

    Note that the first part of the parameters in the URL is correct, ie:
    zoom_query=%22brand+guide%22

    For some reason, elsewhere on your search page, you are sending another copy of the parameters with the query incorrectly escaped:
    zoom_query=\"brand guide\"
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      This is baffling because my code is fairly straightforward, here is the search page, zsearch.php:

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
      	<title>GFS Universe</title>
      	
      	<link rel="stylesheet" type="text/css" href="/inc/gfsU.css" />	
      </head>
      
      <body>
      
      	<?php include "inc/nav.php" ?>
      
      	<div style="margin-left&#58; 25px; margin-bottom&#58; 10px;">
      	
      	<h1>GFS Universe Search</h1>
      
      	
      
      
      	Enter one or more keywords to search for using the GFS Universe search engine.
      
      	Note that '*' and '?' wildcards are supported. To search for an exact phrase surround it with &quot;quotes&quot;.
      	</p>	
      	
      	<?php
          $QSTRING = $_SERVER&#91;'QUERY_STRING'&#93;; 
          while &#40;list &#40;$header, $value&#41; = each &#40;$HTTP_GET_VARS&#41;&#41; 
          &#123; 
          $QSTRING = $QSTRING.'&'.$header.'='.$value; 
          &#125;
          virtual&#40;"/cgi-bin/search.cgi".'?'.$QSTRING&#41;;
        ?>
      	
      	[url="/index.php"][b]Return to GFS Universe Home[/b][/url]
      	</div>
      
      <?php include "inc/footer.php" ?>
      I'm accessing that page directly and getting the error. I am using Server2Go, would that be affecting how the parameter is passed?

      In my search_template.html all I have is styles:

      Code:
      	<!-- 
      	You can change the fonts, colors, and styles of your search results with the CSS below.
      	For some examples and more information on Cascading Style Sheets &#40;CSS&#41;, visit our support page at&#58;
      	http&#58;//www.wrensoft.com/zoom/support/css.html
      	-->
      	<style type="text/css">
      		.highlight &#123; background&#58; #E7DFFF; &#125;
      		.searchheading &#123; font-size&#58; 130%; font-weight&#58; bold; color&#58; #313094; &#125;
      		.summary &#123; font-size&#58; 80%; font-style&#58; italic;&#125; 
      		.results &#123; font-size&#58; 100%; padding&#58; 5px; border&#58; 2px solid #E0DEF8; background-color&#58; #EDECFB; &#125;
      		.category &#123; color&#58; #999999; &#125;
      		.description &#123; font-size&#58; 100%; color&#58; #008000; &#125;
      		.context &#123; font-size&#58; 100%; &#125;
      		.infoline &#123; font-size&#58; 80%; font-style&#58; normal; color&#58; #808080;&#125;
      		.sorting &#123; text-align&#58; right; &#125;
      		.result_title &#123; font-size&#58; 100%; &#125;
      
      		.zoom_searchform &#123; font-size&#58; 100%; &#125;
      		.zoom_options &#123; font-size&#58; 80%; &#125;
      		input.zoom_button &#123;  &#125;
      		input.zoom_searchbox &#123;  &#125;		
      	</style>
      This is how the code appears when the page is rendered using Server2Go:

      Code:
      	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      
      <html>
      <head>
      <title></title>
      
      <link rel="stylesheet" type="text/css" href="inc/gfsU.css" />
      </head>
      <body>
      
      <div id="header">
      	<div id="tabsF">
      	<ul>
      			[*][url="/index.php"]<span>Home</span>[/url]
      			[*][url="zsearch.php"]<span>Search</span>[/url]
      			[*][url="#"]<span>Our Brands</span>[/url]
      			[*][url="#"]<span>Segments</span>[/url]
      			[*][url="#"]<span>Literature</span>[/url]
      			[*][url="#"]<span>Videos</span>[/url]
      			[*][url="#"]<span>Sales Tools</span>[/url]
      			[*][url="#"]<span>Divisions</span>[/url]
      			[*][url="#"]<span>About</span>[/url]
      			[*][url="#"]<span>Help</span>[/url]
      	[/list]
      	</div>
      </div>
      
      <div id="gutter"></div>
      	<div style="margin-left&#58; 25px; margin-bottom&#58; 10px;">
      	
      	<h1>GFS Universe Search</h1>
      
      	
      
      
      	Enter one or more keywords to search for using the GFS Universe search engine.
      
      	Note that '*' and '?' wildcards are supported. To search for an exact phrase surround it with &quot;quotes&quot;.
      	</p>	
      	
      		<!-- 
      	You can change the fonts, colors, and styles of your search results with the CSS below.
      	For some examples and more information on Cascading Style Sheets &#40;CSS&#41;, visit our support page at&#58;
      	http&#58;//www.wrensoft.com/zoom/support/css.html
      	-->
      	<style type="text/css">
      		.highlight &#123; background&#58; #E7DFFF; &#125;
      		.searchheading &#123; font-size&#58; 130%; font-weight&#58; bold; color&#58; #313094; &#125;
      		.summary &#123; font-size&#58; 80%; font-style&#58; italic;&#125; 
      		.results &#123; font-size&#58; 100%; padding&#58; 5px; border&#58; 2px solid #E0DEF8; background-color&#58; #EDECFB; &#125;
      		.category &#123; color&#58; #999999; &#125;
      		.description &#123; font-size&#58; 100%; color&#58; #008000; &#125;
      		.context &#123; font-size&#58; 100%; &#125;
      		.infoline &#123; font-size&#58; 80%; font-style&#58; normal; color&#58; #808080;&#125;
      		.sorting &#123; text-align&#58; right; &#125;
      		.result_title &#123; font-size&#58; 100%; &#125;
      
      		.zoom_searchform &#123; font-size&#58; 100%; &#125;
      		.zoom_options &#123; font-size&#58; 80%; &#125;
      		input.zoom_button &#123;  &#125;
      		input.zoom_searchbox &#123;  &#125;		
      	</style>
      	</style>
      
      <form method="get" action="zsearch.php" class="zoom_searchform">
      Search for&#58; <input type="text" name="zoom_query" size="20" value="" class="zoom_searchbox" />
      <input type="submit" value="Submit" class="zoom_button" />
      <span class="zoom_options">Results per page&#58;
      <select name='zoom_per_page'><option selected="selected">10</option><option>20</option><option>50</option><option>100</option></select>
      
      
      Match&#58; 
      <input type="radio" name="zoom_and" value="0" />any search words
      <input type="radio" name="zoom_and" value="1" checked="checked" />all search words
      <input type="hidden" name="zoom_sort" value="0" />
      </span>
      </form>
      	
      	[url="/index.php"][b]Return to GFS Universe Home[/b][/url]
      	</div>
      
      <div id="footer">All content on this site is &copy; Gordon Food Service&trade; 2006.  All rights reserved.</div>
      
      </body>
      </html>
      The only thing odd I found is the extra closing </style> tag. But that doesn't seem like it would affect the parameters being passed.

      Comment


      • #4
        I don't see any problem with the code above. I suspect that it may be an issue with the PHP configuration on your setup/version of Server2Go.

        I tested your above examples myself using a default install of Server2Go V0.9.11 as well as Server2Go V1.1.0 (latest). It worked fine in both cases without the error you reported.

        However, I did notice that there are a few different Server2Go packages available. The one I tested with was includes only "Apache,PHP,SQLite". It is possible that the other packages, such as the "Apache,PHP,SQLite,MySQL,Perl" one is setup differently. I'll be downloading this and see if it makes any difference. But it might be worth for you to check which package you have, and which one you really need (in case the smaller package works better for you etc.)

        That extra </style> tag in your output is also a bit odd. I'm not sure where that's coming from either and it makes me wonder if theres something missing in what you've posted above. It did not happen when I used your code samples to replicate the test here.
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Update: Just tested the same files on Server2Go 1.1.0 "Apache,PHP,SQLite,MySQL,Perl" package. It worked just fine again, and without problems.

          FYI, Server2Go reports that it is using these versions:
          Apache/1.3.34 (Win32)
          PHP/5.1.2
          SQLite 2
          MySQL 4.1.15
          Perl 5.8
          If you are using an older version of Server2Go, it might be worth trying a newer version. Otherwise, check your Server2Go configurations and see how it differs from the default.
          --Ray
          Wrensoft Web Software
          Sydney, Australia
          Zoom Search Engine

          Comment


          • #6
            I just downloaded a fresh install of Server2Go. The only thing I changed was the local IP address in the config file. Interestingly after more testing I found out that the error only appears with certain keywords. The pattern I'm noticing is that if part of the exact phrase appears in the Zoom index and another part of the exact phrase does not then I get the error.

            For example, "brand guide" generates an error, but "brandss guide" does not.

            The problem with that theory though is that the latter part of the exact phrase, "guide" appears in the index. I'll do some more testing and update the post with my findings.

            Another thing occurred to me, I had enabled indexing of mpg and wmv files so that they would appear in the the results based on filename. I disabled that option and am re-indexing.

            Comment


            • #7
              Taking out the wmv and mpg files from the indexable files types had no effect.

              This index is scanning a compository of food marketing data. Here are more examples of keyphrases generating the error:

              "beef beef"
              "beef beef beef"
              "beef beef beef beef"
              "beef guide"
              "brand guide"
              "guide brand"
              "heritage chicken"
              "chicken heritage"
              "beef purple"
              "purple beef"

              These keyphrases do not generate errors and show the No results found message correctly:

              "beef car"
              "beef stroganof"
              "spaghetti surprise"
              "car guide"
              "brand car"
              "eating out tonight"
              "brand guide car"
              "gordon paul"

              My next test will be to remove all words I have in the Synonyms option of the Zoom index configuration. I'll post my findings.

              Comment


              • #8
                Removing all synonyms had no effect. Hmm any ideas on what to try next?

                Comment


                • #9
                  I'm creating a new index using the Zoom wizard in case there are any settings from the old config that may be causing problems. I'll post the results.

                  Comment


                  • #10
                    Interesting.

                    When I let Zoom generate a new search_template.html I no longer am receiving the error.

                    My output through Server2Go now looks like this:

                    Code:
                    	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                    
                    <html>
                    <head>
                    <title>Search &#58; GFS Universe</title>
                    
                    <link rel="stylesheet" type="text/css" href="inc/gfsU.css" />
                    </head>
                    <body>
                    
                    <div id="header">
                    	<div id="tabsF">
                    	<ul>
                    			[*][url="/index.php"]<span>Home</span>[/url]
                    			[*][url="zsearch.php"]<span>Search</span>[/url]
                    			[*][url="#"]<span>Our Brands</span>[/url]
                    			[*][url="#"]<span>Segments</span>[/url]
                    			[*][url="#"]<span>Literature</span>[/url]
                    			[*][url="#"]<span>Videos</span>[/url]
                    			[*][url="#"]<span>Sales Tools</span>[/url]
                    			[*][url="#"]<span>Divisions</span>[/url]
                    			[*][url="#"]<span>About</span>[/url]
                    			[*][url="#"]<span>Help</span>[/url]
                    	[/list]
                    	</div>
                    </div>
                    
                    <div id="gutter"></div>
                    	<div style="margin-left&#58; 25px; margin-bottom&#58; 10px;">
                    	
                    	<h1>GFS Universe Search</h1>
                    
                    	
                    
                    
                    	Enter one or more keywords to search for using the GFS Universe search engine.
                    
                    	Note that '*' and '?' wildcards are supported. To search for an exact phrase surround it with &quot;quotes&quot;.
                    	</p>	
                    	
                    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                        "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <!-- 
                    This is the search template file &#40;search_template.html&#41; which contains the layout
                    to your search page. 
                    
                    Note that you can not access the search function from this page &#40;by default&#41;. Instead, 
                    you should open or link to the search script, which is a file named "search.php", 
                    "search.asp", or "search.cgi".
                    -->
                    <html>
                    <head>
                    <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
                    	<title>Example Zoom search template page</title>	
                    	<!-- 
                    	You can change the fonts, colors, and styles of your search results with the CSS below.
                    	For some examples and more information on Cascading Style Sheets &#40;CSS&#41;, visit our support page at&#58;
                    	http&#58;//www.wrensoft.com/zoom/support/css.html
                    	-->
                    	<style type="text/css">
                    		.highlight &#123; background&#58; #FFFF40; &#125;
                    		.searchheading &#123; font-size&#58; 130%; font-weight&#58; bold; &#125;
                    		.summary &#123; font-size&#58; 80%; font-style&#58; italic; &#125; 
                    		.results &#123; font-size&#58; 100%; &#125;
                    		.category &#123; color&#58; #999999; &#125;
                    		.description &#123; font-size&#58; 100%; color&#58; #008000; &#125;
                    		.context &#123; font-size&#58; 100%; &#125;
                    		.infoline &#123; font-size&#58; 80%; font-style&#58; normal; color&#58; #808080;&#125;
                    		.sorting &#123; text-align&#58; right; &#125;
                    		.result_title &#123; font-size&#58; 100%; &#125;
                    
                    		.zoom_searchform &#123; font-size&#58; 100%; &#125;
                    		.zoom_options &#123; font-size&#58; 80%; &#125;
                    		input.zoom_button &#123;  &#125;
                    		input.zoom_searchbox &#123;  &#125;		
                    	</style>		
                    </head>
                    
                    <body>
                    	<!-- 
                    	The ZOOMSEARCH tag below marks the place where your search form and search results
                    	will be inserted when you run the search script. By default, you do not need to place a 
                    	search form here, the search script will generate one and display it before the search 
                    	results. Also note that the ZOOMSEARCH tag should be on a seperate line of its own.
                    	-->
                    	<h1>Search this site</h1>
                    	
                    
                    
                    	Enter one or more keywords to search for using the Zoom Search Engine.
                    
                    	Note that '*' and '?' wildcards are supported.
                    	</p>	
                    
                    <form method="get" action="zsearch.php" class="zoom_searchform">
                    Search for&#58; <input type="text" name="zoom_query" size="20" value="&quot;brand guide&quot;" class="zoom_searchbox" />
                    <input type="submit" value="Submit" class="zoom_button" />
                    <span class="zoom_options">Results per page&#58;
                    <select name='zoom_per_page'><option selected="selected">10</option><option>20</option><option>50</option><option>100</option></select>
                    
                    
                    Match&#58; 
                    <input type="radio" name="zoom_and" value="0" />any search words
                    <input type="radio" name="zoom_and" value="1" checked="checked" />all search words
                    <input type="hidden" name="zoom_sort" value="0" />
                    </span>
                    </form>
                    <div class="searchheading">Search results for&#58; &quot;brand guide&quot;</div>
                    
                    <div class="results">
                    <div class="summary">
                    No results found.
                    
                    </div>
                    </div>
                    
                    
                    [size="1"]Search took 0.470 seconds[/size]
                    </body>
                    </html>
                    	
                    	[url="/index.php"][b]Return to GFS Universe Home[/b][/url]
                    	</div>
                    
                    <div id="footer">All content on this site is &copy; Gordon Food Service&trade; 2006.  All rights reserved.</div>
                    
                    </body>
                    </html>
                    I'll tweak this code and follow up.

                    Comment


                    • #11
                      This issue is recurring, I just followed up with an e-mail to info at wrensoft dot net that includes error reporting details, my config file and code snippets.

                      Comment


                      • #12
                        Try taking out this part of the code:
                        while (list ($header, $value) = each ($HTTP_GET_VARS))
                        {
                        $QSTRING = $QSTRING.'&'.$header.'='.$value;
                        }

                        It duplicates your querystring. I was having including the cgi results. I took out that code and it works.

                        Comment

                        Working...
                        X