INSERT INTO - Duplicate entries into table!
Please forgive my rudimentary methods.
I have a form with two fields and a selection box. Entering the information should insert the first, last name, and the value selected from the selection box (only one can be picked so it is not an array). When I submit information I get two entries onto mysql instead of one.
For example I type:
First name: Bill
Last name: Johnson
Skill selected = 146
The table ends up looking like this:
key first_name last_name skill
1 bill johnson 146
2 bill johnson 146
Any thoughts?
___________________________________________________
<?php
$START_TIME = microtime();
$ln = $LASTNAME = $HTTP_POST_VARS['LASTNAME'];
$fn = $FIRSTNAME = $HTTP_POST_VARS['FIRSTNAME'];
$SKILLS = $HTTP_POST_VARS['SKILLS'];
$DOQUERY = $HTTP_POST_VARS['DOQUERY'];
?>
<html>
<head>
</head>
<body>
<?php
$totalskills=sizeof($SKILLS);
// Connect & Select Database //
$link = mysql_connect("localhost", "user","pass") or die("DB Connect Error!!\n");
mysql_select_db("database") or die("Could Not Select Database!!\n");
if($fn=="") {
Print "Error! Please enter a first name! <br>";
}
elseif($ln=="") {
Print "Error! Please enter a last name! <br>";
}
elseif($totalskills==1) {
$val=$SKILLS;
if($SKILLS == $val) {
$query = "INSERT INTO callbacks (first_name, last_name, skill) VALUES ('$fn', '$ln', $val)";
$result = mysql_query($query) or die("<h3>Query Failed!!</h3><br>\n");
mysql_query($query,$link);
}
}
else {
print "Error! Please select a skill";
}
// Close Connection //
mysql_close($link);
?>
</body>
</html>
Subject
Written By
Posted
INSERT INTO - Duplicate entries into table!
June 02, 2005 11:47AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.