Re: [PHP] Matching Question

2001-08-04 Thread Mark Maggelet

On Sat, 4 Aug 2001 12:40:42 -0500, Jeff Oien ([EMAIL PROTECTED])
wrote:
After a sign up page I want to check if someone is already entered
into a database. The First Name, Last Name and Address all have
to match exactly in order for it to be considered a duplicate.
However
this isn't doing what I want. I get the Error produced if the
Address matches
but the name doesn't. Not sure what I'm doing wrong. Thanks.
Jeff Oien

you're going about this the wrong way.
try it like this:

$result=mysql_query(select * from table where first='$first' and
last='$last' and address='$address');

if(mysql_num_rows($result)){
  // error code
}

you want to keep the result sets that mysql gives back as small as
possible because they take up tons of resources.

while ($row = mysql_fetch_array($result)) {
   $First_Name = $row['First_Name'];
   $Last_Name = $row['Last_Name'];
   $Address = $row['Address'];
   
   if (($M_First_Name || $F_First_Name == $First_Name) 
   ($M_Last_Name || $F_Last_Name == $Last_Name)
($Address1 == $Address)) {
   echo 
   htmlheadtitleError/title/head
   body bgcolor=\#FF\ text=\#00\ link=\#ff\
vlink=\#660099\
   h3Error/h3
etc...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: php-list-
[EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Matching Question

2001-08-04 Thread Jeff Oien

Thank you. That worked and I'm sure will have made it work a lot
faster later on when there is a lot of data in the database.
Jeff Oien

 On Sat, 4 Aug 2001 12:40:42 -0500, Jeff Oien ([EMAIL PROTECTED]) 
 wrote:
 After a sign up page I want to check if someone is already entered
 into a database. The First Name, Last Name and Address all have
 to match exactly in order for it to be considered a duplicate. 
 However
 this isn't doing what I want. I get the Error produced if the 
 Address matches 
 but the name doesn't. Not sure what I'm doing wrong. Thanks.
 Jeff Oien 
 
 you're going about this the wrong way.
 try it like this:
 
 $result=mysql_query(select * from table where first='$first' and 
 last='$last' and address='$address');
 
 if(mysql_num_rows($result)){
   // error code
 }
 
 you want to keep the result sets that mysql gives back as small as 
 possible because they take up tons of resources.
 
 while ($row = mysql_fetch_array($result)) {
  $First_Name = $row['First_Name'];
  $Last_Name = $row['Last_Name'];
  $Address = $row['Address'];
  
  if (($M_First_Name || $F_First_Name == $First_Name)  
  ($M_Last_Name || $F_Last_Name == $Last_Name) 
   ($Address1 == $Address)) {
  echo 
  htmlheadtitleError/title/head
  body bgcolor=\#FF\ text=\#00\ link=\#ff\ 
 vlink=\#660099\
  h3Error/h3
 etc...
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: php-list-
 [EMAIL PROTECTED]
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Matching Question

2001-08-04 Thread hassan el forkani

ok,
if i understand you correctly, you're taking data from a form and want to 
check that it is not already in the database, right?
then why don't you include the submitted vars in the query like this:

$sql = SELECT First_Name, Last_Name, Address FROM $table_name
WHERE (Family_Position = 'H' or Family_Position = 'S') and first_name = 
'$form_First_Name' and last_name='$form_last_name' and 
address='$form_address';
$result = @mysql_query($sql,$connection) or die( Couldn't execute query.);
$number_of_matches = mysql_num_rows($result);
if ($number_of_matches  0)
{print bla bla;
else{
//submitted info is ok and can be inserted 
}
please correct me if i missunderstood your question


regards


At 21:52 04/08/01, you wrote:
Here is the query part:

$sql = SELECT First_Name, Last_Name, Address FROM $table_name
WHERE Family_Position = 'H' or Family_Position = 'S';
//$result = @mysql_query($sql,$connection) or die( Couldn't execute query.);
if(! $result = mysql_query($sql,$connection)) {
 print(ERROR .mysql_errno().: 
 .mysql_error().br\n$sqlbr\n);
 }

 
  whta does your query look like?
 
  At 19:40 04/08/01, you wrote:
  After a sign up page I want to check if someone is already entered
  into a database. The First Name, Last Name and Address all have
  to match exactly in order for it to be considered a duplicate. However
  this isn't doing what I want. I get the Error produced if the Address 
 matches
  but the name doesn't. Not sure what I'm doing wrong. Thanks.
  Jeff Oien
  
  while ($row = mysql_fetch_array($result)) {
   $First_Name = $row['First_Name'];
   $Last_Name = $row['Last_Name'];
   $Address = $row['Address'];
  
   if (($M_First_Name || $F_First_Name == $First_Name) 
   ($M_Last_Name || $F_Last_Name == $Last_Name)
($Address1 == $Address)) {
   echo 
   htmlheadtitleError/title/head
   body bgcolor=\#FF\ text=\#00\ link=\#ff\
   vlink=\#660099\
   h3Error/h3
  etc...
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]