Reputation: 51
I have a table in hte same database similar to this that has no difference in syntax or format. Yet I get the above mentioned error? I have done everything I know to fix it, but not sure what I have done wrong. I have an image of the structure as well.
$sql = "INSERT INTO `FormInfo` (`first_name`,
`last_name`,
`company`,
`address`,
`province`,
`postal`,
`telephone`,
`fax`,
`email`,
`comment`)
VALUES ('$good_data[first_name]',
'$good_data[last_name]',
'$good_data[company]',
'$good_data[address]',
'$good_data[province]',
'$good_data[postal]',
'$good_data[telephone]',
'$good_data[email]',
'$good_data[comment]')";
mysqli_query($cxn, $sql) or die ("Couldn't insert into Database: " . mysqli_error($cxn));
What am I missing here?
Upvotes: 0
Views: 481
Reputation: 13713
You are missing insert value for fax
column:
$SQL = "INSERT INTO `FormInfo`
(`first_name`,
`last_name`,
`company`,
`address`,
`province`,
`postal`,
`telephone`,
`fax`,
`email`,
`comment`
)
VALUES (
'$good_data[first_name]',
'$good_data[last_name]',
'$good_data[company]',
'$good_data[address]',
'$good_data[province]',
'$good_data[postal]',
'$good_data[telephone]',
'$good_data[fax]',
'$good_data[email]',
'$good_data[comment]'
)";
Upvotes: 0
Reputation:
try to change,
$sql = "INSERT INTO `FormInfo` (`first_name`, `last_name`, `company`, `address`, `province`, `postal`, `telephone`, `fax`, `email` ,`comment`) VALUES ('$good_data[first_name]', '$good_data[last_name]', '$good_data[company]', '$good_data[address]', '$good_data[province]', '$good_data[postal]', '$good_data[telephone]', '$good_data[email]', '$good_data[comment]')";
to
$sql = "INSERT INTO `FormInfo` (`first_name`, `last_name`, `company`, `address`, `province`, `postal`, `telephone`, `fax`, `email` ,`comment`) VALUES ('$good_data[first_name]', '$good_data[last_name]', '$good_data[company]', '$good_data[address]', '$good_data[province]', '$good_data[postal]', '$good_data[telephone]', '$good_data[email]', '$good_data[comment]', '$good_data[fax]')";
Upvotes: 0
Reputation: 572
You are missing your $good_data[fax]
argument
EDIT: Also, please consider the way you are calling your objects in your array is bad practice. See this for more information
Upvotes: 1