-2
$q = "INSERT INTO `client_t`(`Control_no`, `Client_id`, `Fname`, `Mname`, `Lname`, `Religion`, `Citizenship`, `Address`, `E-mail`, `Monthly_Income`, `Detained`, `Date_detained`, `Age`, `Gender`, `Civil_Status`, `Educ_attain`, `Language`, `Contact_no`, `Spouse`) 
     VALUES ('$_POST[Control_no]','$_POST[Client_id]',$_POST[Fname]','$_POST[Mname]'
        ,'$_POST[Religion]','$_POST[Citizenship]','$_POST[Address]','$_POST[Email]',$_POST[Monthly_Incom]','$_POST[Detained]','$_POST[Date_Detained]','$_POST[Age]','$_POST[Gender]',$_POST[Civil_Status]','$_POST[Educ_Attain]','$_POST[Language]','$_POST[Contact_no]','$_POST[Spouse]')";
     $r = mysql_query( $db,$q);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
C Monts
  • 1
  • 2

2 Answers2

1

As you are using single quotes ('), the var is not detected by the array, so it would introduce $_POST[Control_no] directly in the database.

What you should do is something like this:

$q = "INSERT INTO `client_t`(`Control_no`, `Client_id`, `Fname`, `Mname`, `Lname`, `Religion`, `Citizenship`, `Address`, `E-mail`, `Monthly_Income`, `Detained`, `Date_detained`, `Age`, `Gender`, `Civil_Status`, `Educ_attain`, `Language`, `Contact_no`, `Spouse`) 
 VALUES ('" . $_POST["Control_no"] . "','" . $_POST["Client_id"] . "','" . $_POST["Fname"] . "','" . $_POST["Mname"] . "','" . $_POST["Religion"] . "','" . $_POST["Citizenship"] . "','" . $_POST["Address"] . "','" . $_POST["Email"] . "','" . $_POST["Monthly_Incom"] . "','" . $_POST["Detained"] . "','" . $_POST["Date_Detained"] . "','" . $_POST["Age"] . "','" . $_POST["Gender"] . "','" . $_POST["Civil_Status"] . "','" . $_POST["Educ_Attain"] . "','" . $_POST["Language"] . "','" . $_POST["Contact_no"] . "','" . $_POST["Spouse"] . "')";

That way, you append the $_POST with the double quotes because if you don't type it between double quotes it would be read as constants.

-1

Add this and it will tell you what is wrong

If ($r)    
{
    Echo 'success'
Else 
{
    Echo Mysql_error();
}
Tom
  • 4,257
  • 6
  • 33
  • 49
Gert
  • 360
  • 3
  • 8