Jump to content

[SOLVED] php-mysql data retrieve problem??


naveenbj

Recommended Posts

Hello Friend,

 

I hav a small issue whr i m not able to find out wher i m wrong.

here is the code

<?php
$con=mysql_connect('localhost' , 'com_testuser' , 'testpassword');
if(!$con)
{
die('Could not connect' .mysql_error());
}
else
mysql_select_db('com_nag1',$con);
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$birth = $_POST['birth'];
$radiobutton = $_POST['radiobutton'];
$phone = $_POST['phone'];
$mobile = $_POST['mobile'];
$fax = $_POST['fax'];
$query="INSERT INTO form_info(name, LastName, Email, BirthDate, Gender, Address, Phone, Mobile, Fax)
VALUES ('$name' , '$lastname' , '$email' , '$birth' , '$radiobutton'  ,'$phone'  , '$mobile' , '$fax')";
/*$query="INSERT INTO 'form_info'(FirstName, LastName, Email, BirthDate, Gender, Address, Phone, Mobile, Fax)
      VALUES('$name','$lastname','$email','$birth','$radiobutton','$address','$phone','$mobile','$fax')";*/
if(!mysql_query($query,$con))
{
die('Error' . mysql_error());
}
echo "One record added";
mysql_close();
?>

This code is for retriving data from a form and it will save the data in mysql table.

but from this  code i got this error mesg "ErrorColumn count doesn't match value count at row 1 "

---------------------------

any suggestions would be highly appriciated!!

 

 

Regards,

Nj

Link to comment
Share on other sites

You should have posted your current code. I assume you didn't fix it right or are getting the error on a different query (in another part of the code).

 

In your original post, the query that's commented out is actually correct in terms of number of columns listed match the number of values given.

 

Check that you did something like the following (items in red are missing):

 

$address = $_POST['address'];  // whatever you called the form name

 

$query="INSERT INTO form_info(name, LastName, Email, BirthDate, Gender, Address, Phone, Mobile, Fax)

VALUES ('$name' , '$lastname' , '$email' , '$birth' , '$radiobutton', '$address', '$phone'  , '$mobile' , '$fax')";

 

Link to comment
Share on other sites

You should have posted your current code. I assume you didn't fix it right or are getting the error on a different query (in another part of the code).

 

In your original post, the query that's commented out is actually correct in terms of number of columns listed match the number of values given.

 

Check that you did something like the following (items in red are missing):

 

$address = $_POST['address'];  // whatever you called the form name

 

$query="INSERT INTO form_info(name, LastName, Email, BirthDate, Gender, Address, Phone, Mobile, Fax)

 

VALUES ('$name' , '$lastname' , '$email' , '$birth' , '$radiobutton', '$address', '$phone'  , '$mobile' , '$fax')";

 

 

Thanks "toplay" .

Yes ur idea works for  me:)

 

Regards

Nj

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.