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());

Recommended Answers

All 6 Replies

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

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.

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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.