SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

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:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old June 6th, 2002, 05:08 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
need help with searching.... please

Hi i need to be able to search through my database and the code that I have is not working, please help.... the code is below..., please, i need this to work...

>> this is the search form.. "searchform.html" <<

<html>
<body>

<form action=viewdb.php method=GET>

Search For:
<p>
Search: <input type=text name=name size=25 maxlength=25>
<p>
<input type=submit>

</form>
</body>
</html>

>> this is the results page "viewdb.php" <<

<HTML>
<?php
$db = mysql_connect("sooty3d", "root", "shadow");
mysql_select_db("companies",$db);

$result = mysql_query("SELECT * FROM details where name like '%$name%' order by id",$db);
echo "<TABLE>";
echo"<TR><TD><B>id</B><TD><B>Name</B><TD><B>address</B><TD><B>telephone</B></TR>";
while ($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["id"];
echo "<TD>";
echo $myrow["name"];
echo "<TD>";
echo $myrow["address"];
echo "<TD>";
echo $myrow["phone"];
}
echo "</TABLE>";
?>
</HTML>

Reply With Quote
  #2  
Old June 6th, 2002, 05:17 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: need help with searching.... please

well one main problem i see straight away is that your file is named .html, all files with php code must have a .php extension...

Reply With Quote
  #3  
Old June 6th, 2002, 05:20 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: need help with searching.... please

hi, thanks fro replying but the ".html" file contacins no php info at all, it is just the search box...

Reply With Quote
  #4  
Old June 6th, 2002, 05:29 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: need help with searching.... please

hmm...i ran it on my server (changed it to suite my DB) didnt change any code and it worked...what exactly is the problem? are you getting an error or is it just not searching?

Reply With Quote
  #5  
Old June 6th, 2002, 05:31 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: need help with searching.... please

well, it does work but it doesn't search properly. no matter what I input as a search it always just shows every entry in my database... it is soo annoying me... do you know what it could be??? thanks for the help by the way..

Reply With Quote
  #6  
Old June 6th, 2002, 05:36 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: need help with searching.... please

I have a search thing on one of my own sites
php Code:
Original - php Code
  1.  
  2.  mysql_connect(HOST, USER, PASS);
  3.  $result = mysql_query("SELECT *, UNIX_TIMESTAMP(TIME_POST) AS TIME_POST FROM classifieds WHERE ITEM_NAME LIKE '{$_POST['name']}%' ORDER BY TIME_POST DESC");

this is my code and it works fine..maybe you can find a problem with your by lookin at this

Reply With Quote
  #7  
Old June 6th, 2002, 05:57 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: need help with searching.... please

hi, thanks for all the help[. I haven't been able to use that. All i want to be able to do is a search for a name in the database ad it pattern matches certain names and then lists them. eg. if you typed in "mic", it would result all the names with "m", "i", "c" in them... i just can't do it...

Reply With Quote
  #8  
Old June 6th, 2002, 06:33 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats 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 CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: need help with searching.... please

Is your register globals set on? try using $HTTP_GET_VARS["name"] instead of name?

Reply With Quote
  #9  
Old June 6th, 2002, 06:40 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: need help with searching.... please

sorry, I am just learning this, could you please explain..

Reply With Quote
  #10  
Old June 6th, 2002, 06:46 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats 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 CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: need help with searching.... please

check your c:windowsphp.ini (or wherever ur php.ini file is) for register_globals and check that the value next to it is "on"

or change your code to this (some don't like register_globals coz it makes it easier to make mistakes):

php Code:
Original - php Code
  1.  
  2. <?
  3.   $result = mysql_query("SELECT * FROM details WHERE name LIKE '%".$HTTP_GET_VARS["name"]."%' order by id",$db);
  4. ?>


If you have php 4.1+ then you should be able to use $_GET["name"] instead of $HTTP_GET_VARS["name"] though.

Reply With Quote
  #11  
Old June 6th, 2002, 06:49 PM
runelore runelore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 runelore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: need help with searching.... please

thank you so much for all the help, it is nopw sorted.. you ahve been very helpful, I appreciate it so much.. thank you....

Reply With Quote
  #12  
Old June 6th, 2002, 06:55 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats 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 CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: need help with searching.... please

D1NGO's remark actually tipped me off ;) btw : prolly one of the first rules of debugging : print() or echo() the variable you're trying to use first to check that it's really there as u expect it to be.. it's saved me so much time...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > need help with searching.... please


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway