www.webdeveloper.com
Results 1 to 7 of 7

Thread: PHP/MySQL - Query Error?

  1. #1
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    264

    Exclamation PHP/MySQL - Query Error?

    Ok, so I basically have this:
    PHP Code:
    $query "UPDATE plat SET [name='".$comnm."', city='".$comct."', state='".$comst."', zip='".$comzp."', builder='".$combd."', traffic='".$comtr."', desc='".$comdc."', logo='".$comlg."', hoverlogo='".$comhl."', map='".$commp."', hot_1='".$comh1."', hot_2='".$comh2."', hot_3='".$comh3."', hot_4='".$comh4."', hot_5='".$comh5."', hours_Su='".$comSu."', hours_Mo='".$comMo."', hours_Tu='".$comTu."', hours_We='".$comWe."', hours_Th='".$comTh."', hours_Fr='".$comFr."', hours_Sa='".$comSa."', school_d='".$comsd."', school_e='".$comse."', school_m='".$comsm."', school_h='".$comsh."', utility_sewer='".$comus."', utility_water='".$comuw."', utility_gas='".$comug."', utility_electric='".$comue."', utility_garbage='".$comut."', utility_phone='".$comup."', utility_phone='".$comup."', utility_cable='".$comuc."', mapx='".$commx."', mapy='".$commy."', color_main='".$comcm."', color_comp='".$comcc."', color_accent='".$comca."', status='".$comss."'] WHERE id='".$comid."'" 
    and it seems like a lot, but when the variables are actually filled in it's more like this:

    Code:
    UPDATE plat SET [name='Jacqueline Ridge', city='Marysville', state='WA', zip='98270', builder=' ', traffic=' ', desc='Reliant Homes lends their craftsmanship and quality to this private set of cul–de–sacs bordered by greenbelt. Each of the homes in Jacqueline Ridge are beautiful yet affordable and flexible to your lifestyle.', logo='', hoverlogo='', map='', hot_1='', hot_2='', hot_3='', hot_4='', hot_5='', hours_Su='  ', hours_Mo='  ', hours_Tu='  ', hours_We='  ', hours_Th='  ', hours_Fr='  ', hours_Sa='11001700', school_d=' ', school_e=' ', school_m=' ', school_h=' ', utility_sewer=' ', utility_water=' ', utility_gas=' ', utility_electric=' ', utility_garbage=' ', utility_phone=' ', utility_phone=' ', utility_cable=' ', mapx='', mapy='', color_main='', color_comp='', color_accent='', status=''] WHERE id='3'
    I'm not sure why some of the fields are coming up with spaces in them (I tried using str_ireplace to get rid of them but that doesn't work either...

    Anyway, my actual issue is that it's saying there is a syntax error and I can't spot it, because I'm not that great with this MySQL stuff.

    Any help would be greatly appreciated; thanks!

  2. #2
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    264
    Also, there was an error before I added the square-brackets around them, so that's not my problem either.

  3. #3
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    264
    What I'm doing is trying to create a new database-system (complete with custom CMS) for a Real Estate marketing company. It's not going as well as I'd hoped.

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    try
    PHP Code:
    $query "UPDATE plat SET name='$comnm', city='$comct', state='$comst', zip='$comzp', builder='$combd', traffic='$comtr', desc='$comdc', logo='$comlg', hoverlogo='$comhl', map='$commp', hot_1='$comh1', hot_2='$comh2', hot_3='$comh3', hot_4='$comh4', hot_5='$comh5', hours_Su='$comSu', hours_Mo='$comMo', hours_Tu='$comTu', hours_We='$comWe', hours_Th='$comTh', hours_Fr='$comFr', hours_Sa='$comSa', school_d='$comsd', school_e='$comse', school_m='$comsm', school_h='$comsh', utility_sewer='$comus', utility_water='$comuw', utility_gas='$comug', utility_electric='$comue', utility_garbage='$comut', utility_phone='$comup', utility_phone='$comup', utility_cable='$comuc', mapx='$commx', mapy='$commy', color_main='$comcm', color_comp='$comcc', color_accent='$comca', status='$comss' WHERE id='$comid'" 

  5. #5
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    264
    I tried this:

    PHP Code:
    $query "UPDATE plat SET name='$comnm', city='$comct', state='$comst', zip='$comzp', builder='$combd', traffic='$comtr', desc='$comdc', logo='$comlg', hoverlogo='$comhl', map='$commp', hot_1='$comh1', hot_2='$comh2', hot_3='$comh3', hot_4='$comh4', hot_5='$comh5', hours_Su='$comSu', hours_Mo='$comMo', hours_Tu='$comTu', hours_We='$comWe', hours_Th='$comTh', hours_Fr='$comFr', hours_Sa='$comSa', school_d='$comsd', school_e='$comse', school_m='$comsm', school_h='$comsh', utility_sewer='$comus', utility_water='$comuw', utility_gas='$comug', utility_electric='$comue', utility_garbage='$comut', utility_phone='$comup', utility_phone='$comup', utility_cable='$comuc', mapx='$commx', mapy='$commy', color_main='$comcm', color_comp='$comcc', color_accent='$comca', status='$comss' WHERE id='$comid'"
    But it still gives me this error message:

    Code:
    Query failed -- starting diagnostic output.
    
    errno = `1064'
    
    msg = `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 'desc='Reliant Homes lends their craftsmanship and quality to this private set of' at line 1'
    
    Unable to execute query.
    Failed in db_connect.php on ExecuteQuery() call. Query is:
    UPDATE plat SET name='Jacqueline Ridge', city='Marysville', state='WA', zip='98270', builder=' ', traffic=' ', desc='Reliant Homes lends their craftsmanship and quality to this private set of cul–de–sacs bordered by greenbelt. Each of the homes in Jacqueline Ridge are beautiful yet affordable and flexible to your lifestyle.', logo='', hoverlogo='', map='', hot_1='', hot_2='', hot_3='', hot_4='', hot_5='', hours_Su='  ', hours_Mo='  ', hours_Tu='  ', hours_We='  ', hours_Th='  ', hours_Fr='  ', hours_Sa='11001700', school_d=' ', school_e=' ', school_m=' ', school_h=' ', utility_sewer=' ', utility_water=' ', utility_gas=' ', utility_electric=' ', utility_garbage=' ', utility_phone=' ', utility_phone=' ', utility_cable=' ', mapx='', mapy='', color_main='', color_comp='', color_accent='', status='' WHERE id='3'

  6. #6
    Join Date
    Mar 2012
    Posts
    3

    desc is a keyword

    Hi,

    I do not think you can use "desc" as a field because it is a reserved word. Try to execute the query without updating this field and see if it works.

  7. #7
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    264
    Yes!!! I changed the field to descr and it works!!

    Thank you SO much!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles