Re: false select
| From: | David Robley | Date: | Thu, 29 Jun 2000 02:02:20 +0000 |
| Subject: | Re: false select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3715@lists.php.net to get a copy of this message | ||
On 28 Jun, David VanHorn wrote:
> I'm confused..
> I'm trying to construct a function that will branch depending on wether a
> record is found or not.
> What I have currently is:
>
> if ($Debug) {echo ("Checking for duplicate record<BR>");}
>
> MySQL_db_query('accounts',"SELECT * FROM top_new_contacts
> WHERE
> Name = '$Contact_Name',
> Phone = '$Contact_Phone',
> Email = '$Contact_Email',
> domain = '$Contact_ISP'
> ")
> or die ("No record found<br>");
>
> This works as coded, but I need the inverse.
> If the select gets a record, then I want to echo some statements back to
> the user, and exit.
> If not, then I want to continue execution of the script.
> I'm not having any luck trying to construct this in the form that I need it
> in..
I suspect you'll only 'die' here if the query fails, rather than
returning zero matching rows.
Send your query as something like:
$result = MySQL_db_query('accounts',"SELECT * FROM blah blah blah);
$rows_returned = mysql_num_rows($result);
and then branch according to whether $Rows_returned is zero or not.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA