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. Only one
record per email address is allowed.
Here is a pseudo code version of what I have right now.
function insertStaffer($fname, $lname, $email)
{
$sql = "SELECT table WHERE email = '$email'";
if(1 or more records are found)
{
return 0; // means email address is already used
}
else
{
$sql = "INSERT INTO table ...";
return 1; // assume record inserted correctly
}
}
Now for my question: Should I just assume the INSERT INTO has worked
correctly (like I'm currently doing) and return a 1? Or should I verify
that the INSERT worked correctly (by using the MySQL last_insert_id()
function)?
Alternatively... maybe the mysql_query() function returns a true/false
status based on what happens? Hmm... I should look into that.
I'd appreciate any advice you have to give.
Thanks,
Chris.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php