Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While inserting data in mysql database, data is inserting twice.

Here is my code

PHP
<?PHP
	session_start();
	require("connection.php");
	
	//print_r($_POST);
	
	$ques = $_POST['typeahead'];
	$file_name = '';
	$file_location = '';
	$mess_detail = $_POST['message'];
	
	
	
	$sqlInsert = "insert into querry (user, querry, file_name, file_location, message, date_added) values ('mayank', '".$ques."', '', '', '".$mess_detail."', NOW())";
		
	if(mysql_query($sqlInsert, $conn))
	{
		echo "Successfully Updated....";		
	}
	else
	{
		echo "Failed....";
	}
?>


Here Is my table structure:

SQL
CREATE TABLE IF NOT EXISTS `querry` (
  `querry_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of Querry',
  `user` varchar(20) NOT NULL COMMENT 'user who asked the querry',
  `querry` varchar(255) NOT NULL,
  `file_name` varchar(30) DEFAULT NULL,
  `file_location` varchar(250) DEFAULT NULL,
  `message` varchar(10000) DEFAULT NULL,
  `date_added` datetime NOT NULL,
  PRIMARY KEY (`querry_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


I googled but no luck......
Posted

1 solution

It may your event fire 2 times. Check your code properly you can solve this.
 
Share this answer
 
Comments
mayank.bhuvnesh 21-May-14 4:58am    
Hi Sankarsan

I am call this file on form action and no event has been fired twice..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900