0
 $query = "
        INSERT INTO rets_property_res (ACREAGE, BATHS_FULL, BATHS_HALF, BEDROOMS, CATEGORY, CITY, COUNTY, CO_LA_CODE, CO_LO_CODE, CURRENT_PRICE, DATE_MODIFIED, DIRECTIONS, ELEM_SCHOOL, FTR_APPLIANCE, FTR_CONSTRC_STATUS, FTR_CONSTRUC, FTR_COOLING, FTR_DESIGN, FTR_DININGTYPE, FTR_ENERGY, FTR_EXTERIOR, FTR_FACILITY, FTR_FLOORS, FTR_HEATING, FTR_INTERIOR, FTR_INTERNET, FTR_LOTDESC, FTR_MSTR_BATH_DESC, FTR_MSTR_BDRM_DESC, FTR_PARKING, FTR_POOL, FTR_ROOF, FTR_SIDING, FTR_SPECIAL_SALE_TYPE, FTR_STYLE, FTR_WATERFRONT, FTR_WATERVIEW, HIGH_SCHOOL, INTERMEDIATE_SCHOOL, LA_CODE, LIST_DATE, LIST_PRICE, LOT_DIMENSIONS, LO_CODE, MEDIA_FLAG, MIDDLE_SCHOOL, MLS_ACCT, PHOTO_COUNT, PHOTO_DATE_MODIFIED, PROJ_NAME, PROP_TYPE, REMARKS, STATE, STATUS, STREET_DIR, STREET_NAME, STREET_NUM, SUBDIVISION, TOT_HEAT_SQFT, UNIT_NUM, VT_YN, YEAR_BUILT, ZIP) 
        VALUES (\"$listing[ACREAGE]\", \"$listing[BATHS_FULL]\", \"$listing[BATHS_HALF]\", \"$listing[BEDROOMS]\", \"$listing[CATEGORY]\", \"$listing[CITY]\", \"$listing[COUNTY]\", \"$listing[CO_LA_CODE]\", \"$listing[CO_LO_CODE]\", \"$listing[CURRENT_PRICE]\", \"$listing[DATE_MODIFIED]\", \"$listing[DIRECTIONS]\", \"$listing[ELEM_SCHOOL]\", \"$listing[FTR_APPLIANCE]\", \"$listing[FTR_CONSTRC_STATUS]\", \"$listing[FTR_CONSTRUC]\", \"$listing[FTR_COOLING]\", \"$listing[FTR_DESIGN]\", \"$listing[FTR_DININGTYPE]\", \"$listing[FTR_ENERGY]\", \"$listing[FTR_EXTERIOR]\", \"$listing[FTR_FACILITY]\", \"$listing[FTR_FLOORS]\", \"$listing[FTR_HEATING]\", \"$listing[FTR_INTERIOR]\", \"$listing[FTR_INTERNET]\", \"$listing[FTR_LOTDESC]\", \"$listing[FTR_MSTR_BATH_DESC]\", \"$listing[FTR_MSTR_BDRM_DESC]\", \"$listing[FTR_PARKING]\", \"$listing[FTR_POOL]\", \"$listing[FTR_ROOF]\", \"$listing[FTR_SIDING]\", \"$listing[FTR_SPECIAL_SALE_TYPE]\", \"$listing[FTR_STYLE]\", \"$listing[FTR_WATERFRONT]\", \"$listing[FTR_WATERVIEW]\", \"$listing[HIGH_SCHOOL]\", \"$listing[INTERMEDIATE_SCHOOL]\", \"$listing[LA_CODE]\", \"$listing[LIST_DATE]\", \"$listing[LIST_PRICE]\", \"$listing[LOT_DIMENSIONS]\", \"$listing[LO_CODE]\", \"$listing[MEDIA_FLAG]\", \"$listing[MIDDLE_SCHOOL]\", \"$listing[MLS_ACCT]\", \"$listing[PHOTO_COUNT]\", \"$listing[PHOTO_DATE_MODIFIED]\", \"$listing[PROJ_NAME]\", \"$listing[PROP_TYPE]\", \"$listing[REMARKS]\", \"$listing[STATE]\", \"$listing[STATUS]\", \"$listing[STREET_DIR]\", \"$listing[STREET_NAME]\", \"$listing[STREET_NUM]\", \"$listing[SUBDIVISION]\", \"$listing[TOT_HEAT_SQFT]\", \"$listing[UNIT_NUM]\", \"$listing[VT_YN]\", \"$listing[YEAR_BUILT]\", \"$listing[ZIP]\")";
        $result = mysql_query($query);

我收到此错误:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法,以便在“燃气壁炉上方的电视”附近使用或欣赏海湾的景色。然后在第 2 行打开

我找不到错误。我一直在寻找 2 小时。作为“错误”溢出的内容来自 REMARKS 字段。虽然没有语法错误。

4

2 回答 2

1

尝试这个:

$query = "
    INSERT INTO rets_property_res (ACREAGE, BATHS_FULL, BATHS_HALF, BEDROOMS, CATEGORY, CITY, COUNTY, CO_LA_CODE, CO_LO_CODE, CURRENT_PRICE, DATE_MODIFIED, DIRECTIONS, ELEM_SCHOOL, FTR_APPLIANCE, FTR_CONSTRC_STATUS, FTR_CONSTRUC, FTR_COOLING, FTR_DESIGN, FTR_DININGTYPE, FTR_ENERGY, FTR_EXTERIOR, FTR_FACILITY, FTR_FLOORS, FTR_HEATING, FTR_INTERIOR, FTR_INTERNET, FTR_LOTDESC, FTR_MSTR_BATH_DESC, FTR_MSTR_BDRM_DESC, FTR_PARKING, FTR_POOL, FTR_ROOF, FTR_SIDING, FTR_SPECIAL_SALE_TYPE, FTR_STYLE, FTR_WATERFRONT, FTR_WATERVIEW, HIGH_SCHOOL, INTERMEDIATE_SCHOOL, LA_CODE, LIST_DATE, LIST_PRICE, LOT_DIMENSIONS, LO_CODE, MEDIA_FLAG, MIDDLE_SCHOOL, MLS_ACCT, PHOTO_COUNT, PHOTO_DATE_MODIFIED, PROJ_NAME, PROP_TYPE, REMARKS, STATE, STATUS, STREET_DIR, STREET_NAME, STREET_NUM, SUBDIVISION, TOT_HEAT_SQFT, UNIT_NUM, VT_YN, YEAR_BUILT, ZIP) 
    VALUES (
     '".mysql_real_escape_string($listing['ACREAGE'])."', 
     '".mysql_real_escape_string($listing['BATHS_FULL'])."', '".mysql_real_escape_string($listing['BATHS_HALF'])."', '".mysql_real_escape_string($listing['BEDROOMS'])."', '".mysql_real_escape_string($listing['CATEGORY'])."', '".mysql_real_escape_string($listing['CITY'])."', '".mysql_real_escape_string($listing['COUNTY'])."', '".mysql_real_escape_string($listing['CO_LA_CODE'])."', '".mysql_real_escape_string($listing['CO_LO_CODE'])."', '".mysql_real_escape_string($listing['CURRENT_PRICE'])."', '".mysql_real_escape_string($listing['DATE_MODIFIED'])."', '".mysql_real_escape_string($listing['DIRECTIONS'])."', '".mysql_real_escape_string($listing['ELEM_SCHOOL'])."', '".mysql_real_escape_string($listing['FTR_APPLIANCE'])."', '".mysql_real_escape_string($listing['FTR_CONSTRC_STATUS'])."', '".mysql_real_escape_string($listing['FTR_CONSTRUC'])."', '".mysql_real_escape_string($listing['FTR_COOLING'])."', '".mysql_real_escape_string($listing['FTR_DESIGN'])."', '".mysql_real_escape_string($listing['FTR_DININGTYPE'])."', '".mysql_real_escape_string($listing['FTR_ENERGY'])."', '".mysql_real_escape_string($listing['FTR_EXTERIOR'])."', '".mysql_real_escape_string($listing['FTR_FACILITY'])."', '".mysql_real_escape_string($listing['FTR_FLOORS'])."', '".mysql_real_escape_string($listing['FTR_HEATING'])."', '".mysql_real_escape_string($listing['FTR_INTERIOR'])."', '".mysql_real_escape_string($listing['FTR_INTERNET'])."', '".mysql_real_escape_string($listing['FTR_LOTDESC'])."', '".mysql_real_escape_string($listing['FTR_MSTR_BATH_DESC'])."', '".mysql_real_escape_string($listing['FTR_MSTR_BDRM_DESC'])."', '".mysql_real_escape_string($listing['FTR_PARKING'])."', '".mysql_real_escape_string($listing['FTR_POOL'])."', '".mysql_real_escape_string($listing['FTR_ROOF'])."', '".mysql_real_escape_string($listing['FTR_SIDING'])."', '".mysql_real_escape_string($listing['FTR_SPECIAL_SALE_TYPE'])."', '".mysql_real_escape_string($listing['FTR_STYLE'])."', '".mysql_real_escape_string($listing['FTR_WATERFRONT'])."', '".mysql_real_escape_string($listing['FTR_WATERVIEW'])."', '".mysql_real_escape_string($listing['HIGH_SCHOOL'])."', '".mysql_real_escape_string($listing['INTERMEDIATE_SCHOOL'])."', '".mysql_real_escape_string($listing['LA_CODE'])."', '".mysql_real_escape_string($listing['LIST_DATE'])."', '".mysql_real_escape_string($listing['LIST_PRICE'])."', '".mysql_real_escape_string($listing['LOT_DIMENSIONS'])."', '".mysql_real_escape_string($listing['LO_CODE'])."', '".mysql_real_escape_string($listing['MEDIA_FLAG'])."', '".mysql_real_escape_string($listing['MIDDLE_SCHOOL'])."', '".mysql_real_escape_string($listing['MLS_ACCT'])."', '".mysql_real_escape_string($listing['PHOTO_COUNT'])."', '".mysql_real_escape_string($listing['PHOTO_DATE_MODIFIED'])."', '".mysql_real_escape_string($listing['PROJ_NAME'])."', '".mysql_real_escape_string($listing['PROP_TYPE'])."', '".mysql_real_escape_string($listing['REMARKS'])."', '".mysql_real_escape_string($listing['STATE'])."', '".mysql_real_escape_string($listing['STATUS'])."', '".mysql_real_escape_string($listing['STREET_DIR'])."', '".mysql_real_escape_string($listing['STREET_NAME'])."', '".mysql_real_escape_string($listing['STREET_NUM'])."', '".mysql_real_escape_string($listing['SUBDIVISION'])."', '".mysql_real_escape_string($listing['TOT_HEAT_SQFT'])."', '".mysql_real_escape_string($listing['UNIT_NUM'])."', '".mysql_real_escape_string($listing['VT_YN'])."', '".mysql_real_escape_string($listing['YEAR_BUILT'])."', '".mysql_real_escape_string($listing['ZIP'])."')";
    $result = mysql_query($query);

请注意,这不是最好的方法,您应该使用 MySQLi/PDO 以获得更安全的解决方案。

于 2013-07-26T20:03:27.500 回答
0

老实说..像这样调试非常困难。在 REMARKS 字段中,您可能有未转义的双引号或其他破坏查询编译的字符。您是否尝试过先插入少量数据?

我建议先插入一个“hello world”,然后再对这种插入发疯。

我还建议使用像 '$listing[REMARKS]' 这样的单引号作为默认的 mysql 语法。

于 2013-07-26T20:00:31.360 回答