Re: [PHP] verifying sql INSERTs

2003-08-27 Thread CPT John W. Holmes
From: Curt Zirzow [EMAIL PROTECTED] I should instead just try to perform the INSERT and then if it fails I know I've already got a record. If it doesn't I know everything is cool. I've debated with myself several times if this is really a good method to not have duplicates in the database.

[PHP] verifying sql INSERTs

2003-08-26 Thread Chris W. Parker
Hi! (MySQL) What's the best way to determine a sql INSERT statement has executed successfully? What I've got is a function whose sole purpose is to add new staff members to an app. I've written. There's a basic form that the user fills out (first name, last name, email address) and submits.

Re: [PHP] verifying sql INSERTs

2003-08-26 Thread John W. Holmes
Chris W. Parker wrote: Hi! (MySQL) What's the best way to determine a sql INSERT statement has executed successfully? You should use mysql_error() to ensure your query did not fail for any reason. Assuming the query was successful, you can use mysql_affected_rows() to see if it actually had

Re: [PHP] verifying sql INSERTs

2003-08-26 Thread Marek Kilimajer
mysql_query() will return true for queries that don't return rows and were executed without error, so you can use return mysql_query(); You should also make a UNIQUE index on email column, then you can check the number returned by mysql_errno(), one number I don't remember signals duplicate

RE: [PHP] verifying sql INSERTs

2003-08-26 Thread Chris W. Parker
John W. Holmes mailto:[EMAIL PROTECTED] on Monday, August 25, 2003 5:37 PM said: You should use mysql_error() to ensure your query did not fail for any reason. Assuming the query was successful, you can use mysql_affected_rows() to see if it actually had any impact on the database, i.e.

RE: [PHP] verifying sql INSERTs

2003-08-26 Thread Chris W. Parker
Marek Kilimajer mailto:[EMAIL PROTECTED] on Tuesday, August 26, 2003 3:59 AM said: mysql_query() will return true for queries that don't return rows and were executed without error, so you can use return mysql_query(); You should also make a UNIQUE index on email column, then you can

Re: [PHP] verifying sql INSERTs

2003-08-26 Thread CPT John W. Holmes
From: Chris W. Parker [EMAIL PROTECTED] I should instead just try to perform the INSERT and then if it fails I know I've already got a record. If it doesn't I know everything is cool. If it is a certain kind of failure, then you have a duplicate, otherwise it could be another type of

Re: [PHP] verifying sql INSERTs

2003-08-26 Thread Curt Zirzow
* Thus wrote Chris W. Parker ([EMAIL PROTECTED]): Marek Kilimajer mailto:[EMAIL PROTECTED] on Tuesday, August 26, 2003 3:59 AM said: mysql_query() will return true for queries that don't return rows and were executed without error, so you can use return mysql_query(); You should

RE: [PHP] verifying sql INSERTs

2003-08-26 Thread Chris W. Parker
Curt Zirzow mailto:[EMAIL PROTECTED] on Tuesday, August 26, 2003 11:26 AM said: Like what happens if for some reason the constraint gets dropped? having your progam rely on the constraint will cause all data integrity to go to hell. In that case I hope you're also incrementing your own