Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record duplicates when I insert

Status
Not open for further replies.

wniatbms

Programmer
Dec 5, 2003
24
0
0
ZA
Good day all

I have to pages (.php) to insert data into a MySql DBase. The problem is that it duplicates each new record, ie., it puts the same record in twice.

Here's the code: (the page that receives the form and inserts)

<?
$usernameWS=$_POST['wsUsername'];
$passwordWS=$_POST['wsPassword'];
$firstnameWS=$_POST['wsFirstName'];
$surnameWS=$_POST['wsSurname'];
$emailWS=$_POST['wsUserEmail'];
$mobileWS=$_POST['wsMobile'];
$joindateWS=$_POST['wsJoinDate'];
$hostname = "localhost";
$database = "wnidbase01";
$username = "wni1978";
$password = "infomite";
mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO wsUsers VALUES ('','$usernameWS','$passwordWS','$firstnameWS','$surnameWS','$emailWS','$mobileWS','$joindateWS')";
mysql_query($query);
$result = @mysql_query($query) or die( "<b>Query Failed</b><br>\n".$query."<br>\n".mysql_errno().": ".mysql_error());
mysql_close();
?>

Any help would be most welcome

 
its because you are issuing two calls to mysql_query, lines -3 and -4 in your sample
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top