Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

die message if query unsuccessful...

Posted on 2004-08-10
3
Medium Priority
?
290 Views
Last Modified: 2006-11-17
Hi,
The following is a query to see if a database record matches $sender_email....works fine, but I can't seem to get the 'die' bit to work. i.e. if someone's entered an email which doesn't exist in the records, it doesn't seem to display 'Your record doesn't exist'...

$result=mysql_query("SELECT * FROM members where mem_email='$sender_email'") or die("Your Record does not exist" . mysql_error());
0
Comment
Question by:skylabel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Assisted Solution

by:ThaSmartUno
ThaSmartUno earned 1000 total points
ID: 11769345
0
 
LVL 5

Accepted Solution

by:
winglis4 earned 1000 total points
ID: 11769512
Actually, I believe you are testing for this at the wrong time.

This is from php.net reference on the mysql_query statement.
  Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query()  returns a resource identifier or FALSE if the query was not executed correctly. For other type of SQL statements, mysql_query() returns TRUE on success and FALSE on error. A non-FALSE return value means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows.

You should add your error checking afterwards, with a mysql_num_rows call, or the like.

This is not tested, but I think it should at least point you in the right direction.

$result=mysql_query("SELECT * FROM members where mem_email='$sender_email'");
$numrows = mysql_num_rows($result);
if ($numrows < 1)
   {echo "Your Record does not exist";
    exit;  
}

Good luck!
0
 
LVL 1

Author Comment

by:skylabel
ID: 11769729
thank you ...thank you.....
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question