Jump to content


Photo

Check that database entry exists?


  • Please log in to reply
1 reply to this topic

#1 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 25 August 2006 - 01:02 PM

I'm working on an employee leave program. The employee puts the employee number in and all sorts of wonderful things happen!  :o

But..... if they put in an invalid (nonexistent) employee number or just some gobbledegook, how can I give them a nice, clean "invalid entry" notice as opposed to SQL errors all over the page?


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 25 August 2006 - 01:07 PM

Do a SELECT from database using their empl. number and then check the number of database rows returned from the query result (use mysql_num_rows). If the number of rows returned isn't 1, then their emp. number wasn't found.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users