Re: Database duplicates
| From: | Jon Rosenberg | Date: | Fri, 17 Nov 2000 01:27:04 +0000 |
| Subject: | Re: Database duplicates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25832@lists.php.net to get a copy of this message | ||
You're leaving out evaluating the query
try something like this:
$dup_number_result = mysql_query( "SELECT * FROM dialup WHERE phonenumber =
'".$phonenumber."'", $db_connect );
$num_rows_returned = mysql_num_rows( $dup_number_result );
if ( $num_rows_returned > 0 )
{
print "that number exists!";
exit;
}
----- Original Message -----
From: "Jerry Lake" <jerryl@europa.com>
To: <php-general@lists.php.net>
Sent: Thursday, November 16, 2000 8:06 PM
Subject: RE: [PHP] Database duplicates
> ok, actually it blocks all numbers
> I'm not sure what I've done wrong
> any thoughts
> <snip>
> // select database
> mysql_select_db("$db",$connection);
>
> // formulate and run query
> $verify = "select count(*) from dialup where phoneNumber='$phoneNumber'
and
> areaCode='$areaCode'";
> $test = mysql_query($verify,$connection) or die ("This Bombed");
>
> if ($test > 0)
> {
> echo "This number has been used already";
> }
> else
> {
> inserts the form
> }
> </snip>
>
> Jerry Lake - jerryl@europa.com
> Web Designer
> Europa Communications - http://www.europa.com
> Pacifier Online - http://www.pacifier.com
>
>
> -----Original Message-----
> From: Jamie Alessio [mailto:alessio@mvfx.com]
> Sent: Thursday, November 16, 2000 4:15 PM
> To: Jerry Lake; php-general@lists.php.net
> Subject: Re: [PHP] Database duplicates
>
>
> Why not do something like this before you do an insert....
>
> select count(*) from your_table where phonenumber='$phonenumber' and
> areacode='$areacode'
>
> Then if the value returned from that query is greater than zero you know
> that information
> already exists.
>
> - Jamie
>
> > I'm sifting through the archives right now
> > and can't find anything for my specific problem
> > I brought this up a week or two ago, but am still
> > in a similar spot. I'm adding regional dialup numbers
> > to a MySQL DB and I want to reduce the possibility of
> > redundant data I've got fields for ID, city, state, state abbreviation,
> > area code, phone number and services. I've got the ID set to primary
> > I can't really use the number as primary since potentially there
> > will be the same numbers somewhere albeit a different area code. I
> > just need to know how to stop myself from reentering things that are
> already
> > in the DB...
> > if($phoneNumber == $phonenumber)
> > {
> > echo "alert(quit it)";
> > }
> > something like that?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net