954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ADD New Record Error

Hello i m developing admin panel for my project
i want to add new records
when i fill out the form and hit the add button its redirect me a error message
i dont know how to ride on this error please help thanks!
The error is
Insert failureColumn count doesn't match value count at row 1

$query = "SELECT * FROM person";
	$result = mysql_query($query);
	$nos = mysql_num_rows($result);
	$rno = $nos+1;

	$query = "SELECT * FROM person WHERE fullname = '$parent' LIMIT 1";
	$result = mysql_query($query);
	$objParent = mysql_fetch_object($result);
	
	$query = "INSERT INTO person VALUES('$rno','$name','$gender',$objParent->id,'','$birthday','$email','$profession',
		'$major','$residence','$spousename','$divorceddate','$remarrieddate')";
	$result = mysql_query($query) or die("Insert failure".mysql_error());
tahirkhanafridi
Newbie Poster
20 posts since Dec 2011
Reputation Points: 14
Solved Threads: 0
 

You have more columns than you specified values for. Either specify the columns too, or add the missing values.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

can u tell me that insert query is okey or its not valid i dont specified the columns of my db i just specified the values that i am getting from the user.

tahirkhanafridi
Newbie Poster
20 posts since Dec 2011
Reputation Points: 14
Solved Threads: 0
 

If you do not specify the columns, you have to give a value for every column in the table.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

i have total 12 columns and i putted all them but still this error showing on data inserting plz help me
thanks!

tahirkhanafridi
Newbie Poster
20 posts since Dec 2011
Reputation Points: 14
Solved Threads: 0
 

Show your new query, your table structure, and the error.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

thanks dear its now solved
i have error on this statement VALUES('$rno','$name','$gender',$objParent->id,'','$birthday','$email','$profession',
here you are seeing '' quotes which are empty i just removed it and my code run perfectly thanks

tahirkhanafridi
Newbie Poster
20 posts since Dec 2011
Reputation Points: 14
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You