WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am trying to use jQuery in-place editor (http://code.google.com/p/jquery-in-place-editor/) on WordPress to update certain values of a custom made table in my database.

I am not really skilled with AJAX (first time trying to use it) or MYSQL, that's why I am having difficulties. I will try to explain my problem in the best way possible.

What I want is to change the value of the column (telephone) inside the table (wp_esn_cardholder). Each row has an unique ID (id_cardholder).

I can smoothly run the jQuery in-place js inside the page, calling for "save.php"

<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
      url: "http://example.com/save.php",

With save.php I try to update the value, using the following code

global $wpdb; 

$update_value = $_POST['update_value'];
$element_id = $_POST['element_id'];
$original = $_POST['original_html'];

$table = 'esn_cardholder';
$row_id = $_POST['element_id'];

$data_array = array('telephone' => $_POST['update_value']);
$where_array = array('id_cardholder' => $row_id);
$wpdb->update( $wpdb->prefix . $table, $data_array, $where_array )

Using Firebug's console, I can see that the following passes through:

Parameters application/x-www-form-urlencoded
element_id  278
original_html   old-number
original_value  old-number
update_value    new-number

Source update_value=new-number&element_id=278&original_html=old-number&original_value=old-number

The thing won't update the database, and I obviously don't know why. I know that I should sanitize the query but I can think about that once it works :).

Thanks in advance

share|improve this question
You should use WordPress' built-in AJAX functionality. – Joseph Leedy Sep 13 '12 at 2:22

I had to load WordPress in order to use the wpdb function. How silly :p.

To do so:

$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );

And then finally:

global $wpdb; 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.