SunQuest
           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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 19th, 2003, 05:21 PM
cliffmar cliffmar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 cliffmar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Database Search

I am using a code sample from this site to search my database, Code is as follows

Search for a Client</h3>
<? mysql_select_db($database_cielo_dbcon, $cielo_dbcon);?>
<?
//You should now this but be sure to connect to your database or this is useless. :/
if ($EmailAddress == "EmailAddress")
{$EmailAddress = '%';}

// $user and $passwd are the two column names I used. Change this to fit your database
$result = mysql_query ("SELECT * FROM clients
WHERE EmailAddress LIKE '%$EmailAddress%'
");

if ($row = mysql_fetch_array($result)) {


do {
PRINT "<b>Client Id: </b> ";
print $row["ClientId"];
print (" ");
print ("<br>");
PRINT "<b>First Name: </b> ";
print $row["FirstName"];
print ("<p>");
PRINT "<b>Last Name: </b> ";
print $row["LastName"];
print ("<p>");
PRINT "<b>Address: </b> ";
print $row["Address"];
print ("<p>");
PRINT "<b>City: </b> ";
print $row["City"];
print ("<p>");
PRINT "<b>State: </b> ";
print $row["State"];
print ("<p>");
PRINT "<b>Postal Code: </b> ";
print $row["PostalCode"];
print ("<p>");
PRINT "<b>Phone Number: </b> ";
print $row["PhoneNumber"];
print ("<p>");
PRINT "<b>Email Address: </b> ";
print $row["EmailAddress"];
print ("<p>");
PRINT "<b>Notes: </b> ";
print $row["Notes"];
print ("<p>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}

//The end result prints the username / passwd / firstname / lastname / ID / email
//you will have to change these fields also to fit your needs
?>


But when I enter an email address to search
it returns all email addresses in the database not just the one I was searching for.
Please Help
PHP NEWBIE
Cliff

Reply With Quote
  #2  
Old June 19th, 2003, 11:26 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: PHP Database Search

hmmm...maybe globals are off...change:

WHERE EmailAddress LIKE '%$EmailAddress%'

to:

WHERE EmailAddress LIKE '%$_POST[EmailAddress]%'

Reply With Quote
  #3  
Old June 20th, 2003, 05:12 PM
cliffmar cliffmar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 cliffmar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PHP Database Search

Still does the same thing.?????

Reply With Quote
  #4  
Old June 20th, 2003, 05:18 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: PHP Database Search

change:

$result = mysql_query ("SELECT * FROM clients
WHERE EmailAddress LIKE '%$EmailAddress%'
");

into :
$query = "SELECT * FROM clients
WHERE EmailAddress LIKE '%$EmailAddress%'
";
echo $query;
$result = mysql_query ($query);

then show us what the query ends up looking like....

Reply With Quote
  #5  
Old June 20th, 2003, 11:48 PM
cliffmar cliffmar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 cliffmar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PHP Database Search

Ok Matt, I did what you said and entered the query mac which should have returned no results at all and this is what I got....
Keep in mind this is the only entry in the database at this time.....

SELECT * FROM clients WHERE EmailAddress LIKE '%%'

Client Id: 1

First Name: Michael

Last Name: Dailey

Address: 1180 Some Fake Ave

City: Las Vegas

State: NV

Postal Code: 89123

Phone Number: ***-****

Email Address: mike@futurescapedesign.com

Reply With Quote
  #6  
Old June 21st, 2003, 12:05 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: PHP Database Search

Show me the form you use to enter the email address into....

Reply With Quote
  #7  
Old June 21st, 2003, 10:39 PM
cliffmar cliffmar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 cliffmar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PHP Database Search

Here is the form....

<form method=post action="search.php">
<font size="2" face="Geneva, Arial, Helvetica, sans-serif">
<div align="center">Search For: </div>
</font>
<div align="center"><font size="2"></font></div>
<font size="2">
<p align="center"><font face="Geneva, Arial, Helvetica, sans-serif"> Email
Address:
<input type=text name=user size=25 maxlength=50>
</font>
</font>
<p align="center"> <font size="2" face="Geneva, Arial, Helvetica, sans-serif">
<input type=submit>
</font>
</form>

Youe can see it at..
http://cielosalonandspa.com/find.php

Reply With Quote
  #8  
Old June 21st, 2003, 11:19 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: PHP Database Search

Email
Address:
<input type=text name=user size=25 maxlength=50>


There's the problem...you need to name that input EmailAddress not user...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > PHP Database Search


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 3 hosted by Hostway