Title: Custom phpMyAdmin database with ACF
Last modified: September 1, 2016

---

# Custom phpMyAdmin database with ACF

 *  [clipix68](https://wordpress.org/support/users/clipix68/)
 * (@clipix68)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/custom-phpmyadmin-database-with-acf/)
 * Hi, I have created custom database in phpMyAdmin which I will use together with
   ACF.
    My idea is that the website user make chices with ACF and this info shows
   in the frontend, but I would like to use ACF to query the custom made database.
 * So far this is my code:
 *     ```
       global $wpdb;
       $varA = get_field('city');
       $varB = $wpdb->get_var( "SELECT number FROM database WHERE town = '" .$varA. "'", 0, 1)
       echo $varB;
       ```
   
 * In this case, it seems that the SQL can’t find anything since the $varA is the
   problem. If I echo the variable $varA I get the value from custom field (the 
   value in this case is “Valencia”).
 * I have tried the SQL query with following code and it worked:
 *     ```
       $varB = $wpdb->get_var( "SELECT number FROM database WHERE town  = Valencia", 0, 1)
       echo $varB;
       ```
   
 * For me it seems that the SQL don’t see the the “city” variable $varA as a text.
   Does someone has an idea how to solve this?
 * [https://wordpress.org/plugins/advanced-custom-fields/](https://wordpress.org/plugins/advanced-custom-fields/)

The topic ‘Custom phpMyAdmin database with ACF’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [phpmyadmin](https://wordpress.org/support/topic-tag/phpmyadmin/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 0 replies
 * 1 participant
 * Last reply from: [clipix68](https://wordpress.org/support/users/clipix68/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/custom-phpmyadmin-database-with-acf/)
 * Status: not resolved