Guest User

Untitled

a guest
Jun 18th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. An AJAX HTTP error occurred.
  2. HTTP Result Code: 500
  3. Debugging information follows.
  4. Path: /drupal/?q=system/ajax
  5. StatusText: Service unavailable (with message)
  6. ResponseText: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ajax' in 'where clause': SELECT district_name, country_id,state_id FROM {ajax_district} where id = ajax; Array
  7. (
  8. )
  9. in edit_district_form() (line 291 of /home/mansmu/www/drupal/sites/default/modules/ajaxtest/ajaxtest.district.inc).
  10.  
  11. ////////////////////////////////////////////////////////
  12. ///////// FUNCTION FOR EDIT
  13. ////////////////////////////////////////////////////////
  14. function edit_district_form($form, &$form_state) {
  15. $request_url = request_uri();
  16. // $request_id to get id of edit district.
  17. $request_id = drupal_substr(strrchr($request_url, '/'), 1);
  18.  
  19. //// FOR country
  20. $rows = array();
  21. $result = db_query("SELECT id,country_name from {ajax_country} order by country_name");
  22. while ($data = $result->fetchObject()) {
  23. $id = $data->id;
  24. $rows[$id] = $data->country_name;
  25. }
  26.  
  27. //// FOR state
  28. $state = array();
  29. $result = db_query("SELECT id,state_name from {ajax_state} order by state_name");
  30. while ($data = $result->fetchObject()) {
  31. $id = $data->id;
  32. $state[$id] = $data->state_name;
  33. }
  34.  
  35. // $district_name varible to get name from database for a requested id.
  36. $district_name = db_query("SELECT district_name, country_id,state_id FROM {ajax_district} where id = ".$request_id);
  37. // Loop For show vehicle district name in text field to be update.
  38. foreach ($district_name as $district) {*/
  39. $form['values']['edit_country_name'] = array(
  40. '#type' => 'select',
  41. // '#default_value' => "{$district->country_id}",
  42. '#required' => TRUE,
  43. '#options' => $rows,
  44. '#ajax' => array(
  45. 'effect' => 'fade',
  46. 'progress' => array('type' => 'none'),
  47. 'callback' => 'state_callback_edit',
  48. 'wrapper' => 'replace_edit_state',
  49. ),
  50. );
  51.  
  52. $form['values']['edit_state_name'] = array(
  53. '#type' => 'select',
  54. // '#default_value' => "{$district->state_id}",
  55. '#required' => TRUE,
  56. '#options' => array(),
  57. // The prefix/suffix provide the div that we're replacing, named by #ajax['wrapper'] above.
  58. '#prefix' => '',
  59. '#suffix' => '',
  60. );
  61.  
  62. $form['values']['edit_district_name'] = array(
  63. '#type' => 'textfield',
  64. '#size' => 30,
  65. //'#default_value' => "{$district->district_name}",
  66. '#maxlength' => 80,
  67. '#required' => TRUE,
  68. );
  69. }
  70.  
  71. $form['edit_district_submit'] = array(
  72. '#type' => 'submit',
  73. '#value' => t('Update'),
  74. );
  75. $form['actions']['cancel'] = array(
  76. '#markup' => l(t('Cancel'), 'district'),
  77. );
  78.  
  79. return $form;
  80. }
  81.  
  82. ////////////////////////////////////////////////////////
  83. ///////// FUNCTION FOR AJAX CALL BACK
  84. ////////////////////////////////////////////////////////
  85. function state_callback_edit($form, &$form_state) {
  86. // An AJAX request calls the form builder function for every change.
  87. // We can change how we build the form based on $form_state.
  88. if (!empty($form_state['values']['edit_country_name'])) {
  89. $country_id = $form_state['values']['edit_country_name'];
  90. $rows1 = array();
  91. $result = db_query("SELECT id, state_name from {ajax_state} where country_id = $country_id order by state_name");
  92. while ($data = $result->fetchObject()) {
  93. $id = $data->id;
  94. $rows1[$id] = $data->state_name;
  95. }
  96. $form['edit_state_name']['#options'] = $rows1;
  97. }
  98. return $form['values']['edit_state_name'];
  99. }
  100.  
  101. SELECT district_name, country_id,state_id FROM {ajax_district} where id = ajax;
  102.  
  103. $form['request_id'] = array('#type' => 'value', '#value' => $request_id);
Advertisement
Add Comment
Please, Sign In to add comment