Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 12th, 2004, 06:51 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
more database issues

I have just a couple more databases questions and I promise I won't ask any more.....for a couple days anyways. ;)

I have my DB set up now and I used the harvest script tutorial by Matt to get keywords off the site. But now I need it to search.

I have my text field on my site that is named search_term. But when I type something in and press on search it takes me to a blank page, namely that is called search.php...
Here is my search script:
php Code:
Original - php Code
  1.  
  2. //This is my search script.
  3.  
  4. require('searchclass.php');
  5.  
  6. if(isset ($_POST['submit'])) {
  7.     $search = new Search($_POST['search_term']);
  8.     $results = $search->doSearch();
  9.     if($results) {
  10.         echo "<P><B>Your search results:</b></p>n";
  11.         echo "<P>";
  12.         foreach($results as $row) {
  13.             echo "<a href="{$row['url']}">" . "{$row['url']}</a><br />n";
  14.         }
  15.         echo "</p>n";
  16.     } else {
  17.         $results = $search->doFuzzy();
  18.         echo "<p><b>No matches have been found! ";
  19.         if($results) {
  20.             echo "These pages contain similar words " . "to what you searched for:</b></p>n";
  21.             echo "<p><i>(Similar terms are in parentheses)</i></p>n";
  22.             echo "<p>";
  23.             foreach($results as $row) {
  24.                 echo "a href="{row['url']}">{$row['url']}" . "</a> ({$row['keyword']})<br />n";
  25.             }
  26.             echo "</p>n";
  27.         } else {
  28.             echo "No similar results found either.</b></p>n";
  29.         }
  30.     }
  31. }
  32.  
  33.  


Here is my form to activate the script:
Code:
<form name="Search" method="post" action="search.php">
<input type="Search" name="search_term" size="15" value="search here">
<a href="Search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Go Search','','Graphics/Right/Sliced/3R.png',1)"><img src="Graphics/Right/Sliced/3.png" alt="Go Search!" name="search_term" width="130" height="21" border="0" id="search_term"></a>
</form>



Also, I thought I read somewhere that you cannot have a roll-over image as your submit button for a search. Is this correct?

Thanks for any help,
The Squirrel

Reply With Quote
  #2  
Old March 12th, 2004, 08:34 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 902 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 43 m 54 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: more database issues

Yes your problem is the picture is just a link to search.php as opposed to a submit button which submits the form.

Reply With Quote
  #3  
Old March 12th, 2004, 08:36 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: more database issues

"Also, I thought I read somewhere that you cannot have a roll-over image as your submit button for a search. Is this correct?"

Actually, I think you could work around that if you place the submit button of the form in a div with display:none and then use javascript to submit the form on the 'onclick' event handler of the rollover. In fact, I think you don't even need a submit button, because I perhaps javascript can submit the form without a submit button even being present. This is speculation, but I think it would work.

Reply With Quote
  #4  
Old March 12th, 2004, 09:27 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 902 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 43 m 54 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: more database issues

Yes actually if you name your form you can use the javascript command: document.FormName.submit() or something similar. Of course, this poses a problem if JS is disabled on the browser.

Reply With Quote
  #5  
Old March 15th, 2004, 06:08 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: more database issues

Ok, I'm working on this once more after taking the weekend off. (I'll worry about the rollover lateR)

As it stands now, if I put in the submit button nothing happens still. The URL field changes to something like this "http://eislogan.com/search.php?search_term=
whateverwasinthetextareahere&Submit=Submit"

But it just takes me to the search.php page and nothing is displayed. I am using keywords I know are in my database and I am getting no error messages saying that it's not connecting or anything like that.

Do any of you wizards here have any suggestions?

Thanks,
The Squirrel

Reply With Quote
  #6  
Old March 15th, 2004, 06:40 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: more database issues

Post your form code as it is now. If you can see the querystring in the url, then the form action must be set to GET not POST.

Reply With Quote
  #7  
Old March 15th, 2004, 06:49 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: more database issues

Here is my form code. The form is already set to GET instead of POST. I will cap

Code:
<form name="search_term" method="GET" action="search.php">
<div id="Search Bar" style="position:absolute; left:740px; top:-9px; width:7px; height:470px; z-index:1"><img src="Graphics/Line.png" width="1" height="597"></div>
<div id="Search" style="position:absolute; left:742px; top:95px; width:130; height:150; z-index:3"><img src="Graphics/Right/Sliced/1.png" width="130" height="33"><img src="Graphics/Right/Sliced/2.png" width="130" height="41"><a href="Search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Go Search','','Graphics/Right/Sliced/3R.png',1)">
  
  <img src="Graphics/Right/Sliced/3.png" alt="Go Search!" name="search_term" width="130" height="21" border="0" id="search_term"></a><a href="searchtips.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('SearchTips','','Graphics/Right/Sliced/4R.png',1)"><img src="Graphics/Right/Sliced/4.png" alt="Search Tips" name="SearchTips" width="130" height="21" border="0"></a><img src="Graphics/Right/Sliced/5.png" width="130" height="34"></div>
<div id="Search Field" style="position:absolute; left:750px; top:141px; width:118px; height:30px; z-index:5"> 
    <input type="Search" name="search_term" size="15" value="search unavailable">
	<!--<input name="Submit" type="submit" value="Submit">-->
</div>
</form>


I do not see any errors in the code itself. But I may be missing something...



Reply With Quote
  #8  
Old March 15th, 2004, 06:54 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: more database issues

Note that on the page where you are executing the search query, you are referring to your form elements using the $_POST superglobal. $_POST will not work with a form action of GET, change the form action to POST or...Change all references of $_POST on the search page to $_GET.

Just to clarify, I was not stateing that the action HAD to be set to GET, I was making an observation that because you could see the querystring on the url, that you had already set the action to get.

Reply With Quote
  #9  
Old March 15th, 2004, 07:16 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: more database issues



Ahh ok, my mistake.

I changed everything in my search.php script to $_GET and my forms call for GET but I am still getting the same result. I tried changing everything to POST and $_POST but then it wouldn't even show in the address bar my query.

Reply With Quote
  #10  
Old March 15th, 2004, 07:52 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: more database issues

That is the whole idea behind POST, it is not supposed to show the form values in the address bar,so that is working correctly. It looks like your submit button is named Submit, but you are referencing submit on the search page, so nothing is getting processed because that if statement is returning false and skipping everything....PHP is case sensitive...

Reply With Quote
  #11  
Old March 15th, 2004, 08:49 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: more database issues


Quote:
That is the whole idea behind POST, it is not supposed to show the form values in the address bar,so that is working correctly. It looks like your submit button is named Submit, but you are referencing submit on the search page, so nothing is getting processed because that if statement is returning false and skipping everything....PHP is case sensitive...


Ok, POST is working correctly and everything else appears to be just fine. I guess I skipped over the name of the submit button and the reference to it in the search file. Thanks for all your help!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > more database issues


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |