Jump to content

[SOLVED] PHP / MySQL insert error?


dlindsey

Recommended Posts

I'm getting a syntax error on my insert query and I can't seem to figure it out for the life of me. Maybe one of you could help me out?

 

$sql = "insert into units (address_id, type, number, rent, sqfeet, deposit, key, cleaning, pet, ".
"bedrooms, utilities, baths, levels, parking, pool, appliance, yard, furniture, views, ".
"other1, other2, other3, other4, other5) values (".
"'".$_POST['unit_property_code']."', ".
"'".$_POST['unit_type']."', ".
"'".$_POST['unit_number']."', ".
$_POST['unit_rent'].", ".
$_POST['unit_sqfeet'].", ".
$_POST['unit_deposit'].", ".
$_POST['unit_key'].", ".
$_POST['unit_cleaning'].", ".
$_POST['unit_pet'].", ".
"'".$_POST['unit_bedrooms']."', ".
"'".$_POST['unit_utilities']."', ".
"'".$_POST['unit_baths']."', ".
"'".$_POST['unit_levels']."', ".
"'".$_POST['unit_parking']."', ".
"'".$_POST['unit_pool']."', ".
"'".$_POST['unit_appliance']."', ".
"'".$_POST['unit_yard']."', ".
"'".$_POST['unit_furniture']."', ".
"'".$_POST['unit_views']."', ".
"'".$_POST['unit_other1']."', ".
"'".$_POST['unit_other2']."', ".
"'".$_POST['unit_other3']."', ".
"'".$_POST['unit_other4']."', ".
"'".$_POST['unit_other5']."')";

print $sql."<br />";

$result = mysql_query($sql, $cn) or die(mysql_error());

 

And the error page, along with the printed sql query is:

 

insert into units (address_id, type, number, rent, sqfeet, deposit, key, cleaning, pet, bedrooms, utilities, baths, levels, parking, pool, appliance, yard, furniture, views, other1, other2, other3, other4, other5) values ('AVE246', 'single', '', 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 'a', 'b', 'd', 'e', 'g', 'h', 'j', 'k', 'm', 'n', 'c', 'f', 'i', 'l', 'o')


You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, cleaning, pet, bedrooms, utilities, baths, levels, parking, pool, appliance' at line 1

Link to comment
https://forums.phpfreaks.com/topic/175292-solved-php-mysql-insert-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.