I am working on a php-mysql project.

My table contains a field called "ID", which i have declared as teh PRIMARY key.

but what i want is, that when the user tries ot insert record B into the table, an ERROR message should be displayed, showing that a record already exists with primary key =100....

I tried doing this as follows:

if('$id' in (mysql_query("Select ID from client") ))
        echo "ERROR!";

           run the query...

someone please help...

$query = "select * from table where id = 100";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0 ) {
// record already exists
} else {
 // record doesn't exist, so insert.. 

hey thx.... i'll try the code, and get bak 2 u!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.