Jump to content

Need Help Resolving A Fatal Error Using A Query In Php


ready2drum
 Share

Recommended Posts

After entering a search term and clicking on the 'search' button, the following error message appears:_________Notice: Undefined index: query in E:\Inetpub\wwwroot\Intranet_Old\intranet\jha\jha_doc_results.php on line 62Fatal error: Uncaught exception 'com_exception' with message 'Parameter 0: Type mismatch. ' in E:\Inetpub\wwwroot\Intranet_Old\intranet\jha\jha_doc_results.php:62 Stack trace: #0 E:\Inetpub\wwwroot\Intranet_Old\intranet\jha\jha_doc_results.php(62): unknown() #1 {main} thrown in E:\Inetpub\wwwroot\Intranet_Old\intranet\jha\jha_doc_results.php on line 62<td class="fstyle_5"><form id="form1" name="form1" method="post" action="jha_doc_results.php">_________See code below for line 62 details:__

<td class="fstyle_5"><form id="form1" name="form1" method="post" action="jha_doc_results.php">								    <p>								      <input name="query" type="text" class="fstyle_5" id="query" size="60" /> 								      <input name="Submit" type="submit" class="fstyle_1" value="Search" />								    </p>								   								      </form>								</td><?php					$Q = new COM("ixsso.Query");					$util = new COM("ixsso.util");					$Q->Catalog = "\\cbva006file1\GROUP\BIWeb\jha";					$Q->Query = $_POST["query"];					$Q->Columns = "filename, rank, vpath, path, DocTitle, characterization, All";					$Q->SortBy = "rank[d]";					$Q->MaxRecords = 200;					$fileRS = $Q->CreateRecordSet("nonsequential");					if(!$fileRS->RecordCount == 0) {							$fileRS->MoveFirst();					}					while($i < $fileRS->RecordCount) {						?>					<div id="search_results">                          <table width="100%" border="0" cellpadding="0">                            <tr>                              <td height="20" class="fstyle_4"><?php echo($fileRS->fields['DocTitle']->value); ?></td>                            </tr>                            <tr>                              <td class="fstyle_5"><a href="<?php echo($fileRS->fields['path']->value); ?>"><?php echo($fileRS->fields['filename']->value); ?></a></td>                            </tr>                            <tr>                              <td class="fstyle_5"><?php echo($fileRS->fields['characterization']->value); ?></td>                            </tr>                            <tr>                              <td class="fstyle_5"><hr /></td>                            </tr>                          </table>                      </div>					<?php 						$fileRS->MoveNext();						$i++;						} 					?>            					</td>

__I have tried several different methods to resolve this error without success. I'm new to this and am not sure how to set the form to $_POST so that this search feature will work properly.Your suggestions and assistance are greatly appreciated!

Link to comment
Share on other sites

Which line is 62? The code isn't checking if the form was submitted, it just always runs. The first time the page loads without the form getting submitted, when that code runs it will show the undefined index error because the form hasn't been submitted yet. You can check if the form was submitted before running the code. e.g.:if (isset($_POST['Submit']))

Link to comment
Share on other sites

Which line is 62? The code isn't checking if the form was submitted, it just always runs. The first time the page loads without the form getting submitted, when that code runs it will show the undefined index error because the form hasn't been submitted yet. You can check if the form was submitted before running the code. e.g.:if (isset($_POST['Submit']))
I really appreciate your help on this....line 62 is the one that reads: $Q->Query = $_POST["query"];does the code item you mentioned below go under line 62?: if (isset($_POST['Submit']))----
Link to comment
Share on other sites

No, you need to wrap all of that PHP code in an if statement that checks to make sure the form was submitted before it tries to process the information. Since your submit button has the name "Submit", checking if $_POST['Submit'] is set will tell you if the form was submitted. Obviously, there aren't any search results if they haven't searched for anything yet.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...