Faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 6 people (67%) answered Yes
Recently 3 of 5 people (60%) answered Yes

Entry

How do I get a return that lets me know that a depulicate exists and cannot be inserted in mySQL using PHP?

Sep 6th, 2003 01:42
Chukwuma Uzoma-Nze, Jeff Guy,


I am going to use the example of inserting crypted passwords into a 
MySQL database:
you simply verify the user inputed password "$usr_pwd" against the 
databse password "$db_pwd" and if they match you proceed:
$query = mysql_query("select pwd from auth where pwd = "$usr_pwd" ", 
$conn);
$queryArray = mysql_fetch_array($query);
//$queryArray[0] will be your result u can echo it!
$db_pwd = $queryArray[0]; //You can put "$queryArray[0]" directly 
                          //into the statement if u wish, I do!
if(isset($db_pwd)
{
return true
}
elseif(empty($db_pwd))
{
return false
}