Title: WPDB get row problem
Last modified: August 21, 2016

---

# WPDB get row problem

 *  Resolved [digico](https://wordpress.org/support/users/digico/)
 * (@digico)
 * [13 years ago](https://wordpress.org/support/topic/wpdb-get-row-problem/)
 * Using the following code:
 * `$sql = "SELECT * FROM`” . $aDatabaseSettings[‘table’] . “`WHERE`order_id`= '".
   $iBookingId . "' ORDER BY`id` DESC LIMIT 1;”;
    $aRecord = $wpdb->get_row($sql,
   ARRAY_A);
 *  if( is_array($aRecord)) error_log(“YES I AM AN ARRAY”);
    else error_log(“NONONO”.
   gettype($aRecord));
 *  error_log(“aRecord sql: “.$sql);
    error_log(print_r($aRecord, true).”MEER”.$
   aRecord[‘transaction_id’]);`
 * As you can see I am trying to debug already. The thing is that the sql var returns
   a query which works perfectly when executing in phpmyadmin. So although this 
   query is correct the get_row returns NULL. Also added global wpdb; before this
   code.
 * I am searching like crazy but can’t seem to find the problem.
 * Probably simple and stupid problem but need someone who can send me into the 
   right direction to solve this.
 * Hoping on some advice.

Viewing 1 replies (of 1 total)

 *  Thread Starter [digico](https://wordpress.org/support/users/digico/)
 * (@digico)
 * [13 years ago](https://wordpress.org/support/topic/wpdb-get-row-problem/#post-3760134)
 * Problem solved. Caused by bug in code…at moment of executing the code transaction_id
   was not available yet. However after the full action it was, which was the reason
   the sql did execute correctly when trying in phpMyAdmin.

Viewing 1 replies (of 1 total)

The topic ‘WPDB get row problem’ is closed to new replies.

## Tags

 * [NULL](https://wordpress.org/support/topic-tag/null/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 1 reply
 * 1 participant
 * Last reply from: [digico](https://wordpress.org/support/users/digico/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/wpdb-get-row-problem/#post-3760134)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
