| | |
conditional execution of Sql query thru PHP
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
Hi.
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 [B]ERROR message[/B] 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!";
}
else
{
run the query...
}
someone please help...
thx...
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 [B]ERROR message[/B] 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!";
}
else
{
run the query...
}
someone please help...
thx...
php Syntax (Toggle Plain Text)
$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.. }
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the MySQL Forum
- Previous Thread: problem with project in mysql
- Next Thread: incremental backup
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api aws bizspark breathalyzer changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






