Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL][PHP] Zapytanie nie aktualizuje bazy danych
Forum PHP.pl > Forum > Przedszkole
patryk9200
Witam,
Mam taki problem, zapytanie które powinno aktualizować rekord nie aktualizuje go ani nie zwraca żadnego błędu.
Co może być przyczyną?
  1. mysql_query("UPDATE ".dbprefix."offerlist SET `StartDate`='2010-08-08 10:21:08',`EndDate`='2050-01-01 10:21:08',`OfferDay`='0',
  2. `mobile_ID`='".$_SESSION['offer'][$_offerID]['add']['mobilede_ID']."',`autosPicturesArray`='".addslashes($_SESSION['offer'][$_offerID]['add']['autos_pictures_array']) ."',
  3. `OfferType`='".$_SESSION['offer'][$_offerID]['add']['body_types']."',`Mark`='".$_SESSION['offer'][$_offerID]['add']['mark']."',
  4. `Model`='".$_SESSION['offer'][$_offerID]['add']['model']."',`Category`='".$_SESSION['offer'][$_offerID]['add']['auto_type']."',
  5. `Title`='".addslashes($_SESSION['offer'][$_offerID]['add']['title'])."',`Price`='".$_SESSION['offer'][$_offerID]['add']['price']."',
  6. `Currency`='".$_SESSION['offer'][$_offerID]['add']['currency']."',`EngineType`='".$_SESSION['offer'][$_offerID]['add']['petrol']."',
  7. `EngineDesignation`='".$_SESSION['offer'][$_offerID]['add']['engine_designation']."',`EnginePower`='".$_SESSION['offer'][$_offerID]['add']['engine_power']."',
  8. `EnginePowerUnit`='1',`EngineCapacity`='".$_SESSION['offer'][$_offerID]['add']['capacity']."',`Yearbook`='".$_SESSION['offer'][$_offerID]['add']['year']."',
  9. `Mileage`='".$_SESSION['offer'][$_offerID]['add']['mileage']."',`VehicleCondition`='".$_SESSION['offer'][$_offerID]['add']['vehicle_condition']."',
  10. `DoorsNumber`='".$_SESSION['offer'][$_offerID]['add']['doors_number']."',`Color`='".$_SESSION['offer'][$_offerID]['add']['body_color']."',
  11. `ColorType`='".$_SESSION['offer'][$_offerID]['add']['color_type']."',`WhereIsVehicle`='".$_SESSION['offer'][$_offerID]['add']['where_is'] ."',
  12. `SeatsNumber`='".$_SESSION['offer'][$_offerID]['add']['seats_number']."',`SportSeats`='".$_SESSION['offer'][$_offerID]['add']['sports_seats']."',
  13. `GearsNumber`='".$_SESSION['offer'][$_offerID]['add']['gears_number']."',`Radio`='".$_SESSION['offer'][$_offerID]['add']['radio_type']."',
  14. `RadioModel`='".$_SESSION['offer'][$_offerID]['add']['radio_marka_model']."',`ElectricWindows`='".$_SESSION['offer'][$_offerID]['add']['electric_windows'] ."',
  15. `4x4`='".$_SESSION['offer'][$_offerID]['add']['x4x4']."',`Pneumatic`='".$_SESSION['offer'][$_offerID]['add']['pneumatic'] ."',
  16. `ChildSeatsIsofix`='".$_SESSION['offer'][$_offerID]['add']['children_seats_isofix'] ."',`Quattro`='".$_SESSION['offer'][$_offerID]['add']['quattro']."',
  17. `ABS`='".$_SESSION['offer'][$_offerID]['add']['ABS']."',`AirBags`='".$_SESSION['offer'][$_offerID]['add']['air_bag']."',
  18. `CarAlarm`='".$_SESSION['offer'][$_offerID]['add']['alarm']."',`Wheels`='".$_SESSION['offer'][$_offerID]['add']['wheels']."',
  19. `ASR`='".$_SESSION['offer'][$_offerID]['add']['ASR']."',`AutomaticGears`='".$_SESSION['offer'][$_offerID]['add']['automatic_transmission']."',
  20. `AutomaticRearviewMirror`= '".$_SESSION['offer'][$_offerID]['add']['automatic_rear_view_mirrors']."',`CentralLocking`='".$_SESSION['offer'][$_offerID]['add']['central_locking']."',
  21. `TintedGlass`='".$_SESSION['offer'][$_offerID]['add']['tinted_glass']."',`RainSensor`='".$_SESSION['offer'][$_offerID]['add']['rain_sensor']."',
  22. `PartialSkin`='".$_SESSION['offer'][$_offerID]['add']['partial_skin']."',`ExtrasSkin`='".$_SESSION['offer'][$_offerID]['add']['addons_in_leather']."',
  23. `ElectricMirrors`='".$_SESSION['offer'][$_offerID]['add']['electric_mirrors']."',`ElectricallyAdjustableSeats`='".$_SESSION['offer'][$_offerID]['add']['electrically_adjustable_seats']."',
  24. `ESP`='".$_SESSION['offer'][$_offerID]['add']['esp']."',`Air-conditionedSeats`='".$_SESSION['offer'][$_offerID]['add']['air_conditioning_seats']."',
  25. `HeatedSeats`='".$_SESSION['offer'][$_offerID]['add']['heated_seats']."',`SeatsWithMemory`='0',
  26. `ChildSeats`='".$_SESSION['offer'][$_offerID]['add']['child_seats'] ."',`Warranty`= '".$_SESSION['offer'][$_offerID]['add']['guarantee']."',
  27. `Hith`='".$_SESSION['offer'][$_offerID]['add']['hook']."',`Halogens`='".$_SESSION['offer'][$_offerID]['add']['halogens']."',
  28. `TelephoneInstallation`='".$_SESSION['offer'][$_offerID]['add']['telephone_instalation']."',`Klimatronic`='".$_SESSION['offer'][$_offerID]['add']['klimatronic']."',
  29. `AirConditioning`='".$_SESSION['offer'][$_offerID]['add']['air_conditioning'] ."',`On-boardComputer`='".$_SESSION['offer'][$_offerID]['add']['on_board_computer']."',
  30. `ServiceBook`='".$_SESSION['offer'][$_offerID]['add']['service_book']."',`MultimediaSteeringWheel`='".$_SESSION['offer'][$_offerID]['add']['multimedia_steering']."',
  31. `Multitronic`='".$_SESSION['offer'][$_offerID]['add']['multitronic']."',`Navigation`='".$_SESSION['offer'][$_offerID]['add']['navigation']."',
  32. `EuroStandard`='0',`HeatedWindscreen`='".$_SESSION['offer'][$_offerID]['add']['heated_windshield']."',`AuxiliaryHeating`='".$_SESSION['offer'][$_offerID]['add']['auxiliary_heating']."',
  33. `DoubleCab`='0',`Parktronic`='".$_SESSION['offer'][$_offerID]['add']['parctronic']."',`Pilot`='".$_SESSION['offer'][$_offerID]['add']['pilot']."',
  34. `PneumaticSuspension`='".$_SESSION['offer'][$_offerID]['add']['pneumatic']."',`Rails`='".$_SESSION['offer'][$_offerID]['add']['railings']."',
  35. `Skin`='".$_SESSION['offer'][$_offerID]['add']['leather']."',`Sunroof`='".$_SESSION['offer'][$_offerID]['add']['sunroof']."',
  36. `ElectricSunroof`='".$_SESSION['offer'][$_offerID]['add']['electric_sunroof']."',`Immobilizer`='".$_SESSION['offer'][$_offerID]['add']['immobilizer']."',
  37. `Tachograph`='0',`TCS`='".$_SESSION['offer'][$_offerID]['add']['TCS']."',`CruiseControl`='".$_SESSION['offer'][$_offerID]['add']['tempomat']."',
  38. `Tiptronic`='".$_SESSION['offer'][$_offerID]['add']['tiptronic']."',`Velvet`='".$_SESSION['offer'][$_offerID]['add']['velvet']."',
  39. `PowerSteering`='".$_SESSION['offer'][$_offerID]['add']['power_steering']."',`Xenons`='".$_SESSION['offer'][$_offerID]['add']['xenons']."',
  40. `XenonsLight`='".$_SESSION['offer'][$_offerID]['add']['xenons_light']."',`WiperLights`='".$_SESSION['offer'][$_offerID]['add']['wiper_lights']."',
  41. `AdditionalInformation`='".addslashes($_SESSION['offer'][$_offerID]['add']['additional_information'])."',`AdditionalContact`='".addslashes($_SESSION['offer'][$_offerID]['add']['dealer_id_list'])."',
  42. `ParticulateFilter`='".$_SESSION['offer'][$_offerID]['add']['particulate_filter']."',`HeatedOutsideMirrors`='".$_SESSION['offer'][$_offerID]['add']['heated_outside_mirrors']."',
  43. `BluetoothTelephoneConnect`='".$_SESSION['offer'][$_offerID]['add']['bluetooth_telephone_connect']."',`VehicleDynamicControl`='".$_SESSION['offer'][$_offerID]['add']['vehicle_dynamic_control'] ."',
  44. `FPS`='".$_SESSION['offer'][$_offerID]['add']['FPS']."',`USBinterface`='".$_SESSION['offer'][$_offerID]['add']['USB_interface']."',
  45. `AluminiumFinish`='".$_SESSION['offer'][$_offerID]['add']['aluminium_finish']."',`LightSensor`='".$_SESSION['offer'][$_offerID]['add']['light_sensor']."',
  46. `PowerBrakes`='".$_SESSION['offer'][$_offerID]['add']['power_brakes']."',`DSG`='".$_SESSION['offer'][$_offerID]['add']['DSG']."',
  47. `Climatic`='".$_SESSION['offer'][$_offerID]['add']['climatic']."',`FinishInSkin`='".$_SESSION['offer'][$_offerID]['add']['finish_in_skin']."',
  48. `4x2`='".$_SESSION['offer'][$_offerID]['add']['x4x2']."',`Kinetic`='".$_SESSION['offer'][$_offerID]['add']['kinetic']."',
  49. `Serviced`='".$_SESSION['offer'][$_offerID]['add']['serviced']."',`SportSteering`='".$_SESSION['offer'][$_offerID]['add']['sport_steering']."',
  50. `BiXenons`='".$_SESSION['offer'][$_offerID]['add']['bi_xenons']."',`LeatherSteeringWheel`='".$_SESSION['offer'][$_offerID]['add']['leather_steering_wheel']."',
  51. `ChromeFinish`='".$_SESSION['offer'][$_offerID]['add']['chrome_finish']."',`GlassRoof`='".$_SESSION['offer'][$_offerID]['add']['glass_roof']."' WHERE `id` = '".$_SESSION['offer'][$_offerID]['add']['mysql_id']."'")
  52. or die("error offer.content: " . mysql_error());
krispak
  1. WHERE `id` = '".$_SESSION['offer'][$_offerID]['add']['mysql_id']."'")

Sprawdz czy to co przypisujesz do id nie jest puste.
patryk9200
nie, na pewno, z ciekawości wywołałem to jako string i wyszło mi takie zapytanie:
  1. UPDATE _offerlist SET `StartDate`='2010-08-08 10:21:08',`EndDate`='2050-01-01 10:21:08',`OfferDay`='0', `mobile_ID`='',`autosPicturesArray`='', `OfferType`='7',`Mark`='91', `Model`='3',`Category`='1', `Title`='2',`Price`='9317', `Currency`='2',`EngineType`='2', `EngineDesignation`='17',`EnginePower`='105', `EnginePowerUnit`='1',`EngineCapacity`='1900',`Yearbook`='2006', `Mileage`='68250',`VehicleCondition`='2', `DoorsNumber`='2',`Color`='0', `ColorType`='1',`WhereIsVehicle`='2', `SeatsNumber`='',`SportSeats`='', `GearsNumber`='',`Radio`='3', `RadioModel`='',`ElectricWindows`='1', `4x4`='',`Pneumatic`='', `ChildSeatsIsofix`='',`Quattro`='', `ABS`='1',`AirBags`='', `CarAlarm`='',`Wheels`='1', `ASR`='',`AutomaticGears`='', `AutomaticRearviewMirror`= '',`CentralLocking`='1', `TintedGlass`='',`RainSensor`='', `PartialSkin`='',`ExtrasSkin`='', `ElectricMirrors`='',`ElectricallyAdjustableSeats`='', `ESP`='',`Air-conditionedSeats`='', `HeatedSeats`='',`SeatsWithMemory`='0', `ChildSeats`='',`Warranty`= '', `Hith`='',`Halogens`='', `TelephoneInstallation`='',`Klimatronic`='1', `AirConditioning`='1',`On-boardComputer`='', `ServiceBook`='',`MultimediaSteeringWheel`='', `Multitronic`='',`Navigation`='', `EuroStandard`='0',`HeatedWindscreen`='',`AuxiliaryHeating`='', `DoubleCab`='0',`Parktronic`='',`Pilot`='', `PneumaticSuspension`='',`Rails`='', `Skin`='',`Sunroof`='', `ElectricSunroof`='',`Immobilizer`='', `Tachograph`='0',`TCS`='',`CruiseControl`='', `Tiptronic`='',`Velvet`='', `PowerSteering`='1',`Xenons`='', `XenonsLight`='',`WiperLights`='', `AdditionalInformation`='0',`AdditionalContact`='42', `ParticulateFilter`='',`HeatedOutsideMirrors`='', `BluetoothTelephoneConnect`='',`VehicleDynamicControl`='', `FPS`='',`USBinterface`='', `AluminiumFinish`='',`LightSensor`='', `PowerBrakes`='',`DSG`='', `Climatic`='',`FinishInSkin`='', `4x2`='',`Kinetic`='', `Serviced`='',`SportSteering`='', `BiXenons`='',`LeatherSteeringWheel`='', `ChromeFinish`='',`GlassRoof`='' WHERE `id` = '30161'
krispak
Wiec wrzuc to do np. w phpmyadmin jako zapytanie sql i zobacz co zwroci..
patryk9200
dziwne, zadziałało prze PhpMyAdmin to samo nie zmienione zapytanie działa,
dziwna sprawa...
bartoland
Na początku powiem, że wielkiego doświadczenia nie mam ale:

Ja bym poszukał błędu w następujący sposób.
Pozostawił bym w wyrażeniu na początek tylko jedno pole do zmiany - jeśli działa znaczy ze formuła wyrażenia jest ok, tylko gdzieś jest byk w którymś ze sformułowań. A wiec całość dzielę na pół i próbuje czy pierwsza połowa zadziała, jeśli tak to znaczy, że w drugiej połowie jest coś nie tak. Dziele na mniejsze porcje aż znajdę dziada.

Pozdrawiam.
everth
A co ci pokaże mysql_affected_rows() zaraz po update? Jeszcze co przychodzi mi na myśl to to, czy czasem nie masz otwartej wcześniej transakcji?
thek
Skoro przez PMA działa to problem może być gdzieś w apostrofach. Możliwe, że wpisując gdzieś wartości następują one w wersji bez znaku ucieczki i niejako robią lukę. Coś w stylu
  1. mysql_query( 'SELECT * FROM tabela WHERE kolumna = 'wartosc' LIMIT 3' );

Zobacz, że wywalić się to musi, bo wartosc jest poza wszystkim i obejmujące ją apostrofy są niezaescape'owane. powinno tam być kolumna = \'wartosc\'
Taki błąd przy ogromnym zapytaniu trudno wychwycić.
everth
@thek: ale ten string (tak mi się wydaje) jest wygenerowanym zapytaniem PHP i raczej działa (bo sprawdzał). Poza tym sprawdziłem kod - nie wywaliło żadnego błędu, więc raczej nie ten trop.
patryk9200
dobra dzięki, już mam :-)
a błąd leżał po stronie warunku if, przez przypadek paręnaście linijek wyżej skopiował mi się warunek, chociaż nie wiem jakim sposobem powodowało, że tylko zapytanie działało nie poprawnie ;P niby pytanie się wykonywało ale nie było widać wyników. W każdym razie wszystko działa i dzięki za pomoc winksmiley.jpg
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.