Title: mysql syntax error, help please.
Last modified: August 18, 2016

---

# mysql syntax error, help please.

 *  [esgaroth](https://wordpress.org/support/users/esgaroth/)
 * (@esgaroth)
 * [21 years, 9 months ago](https://wordpress.org/support/topic/mysql-syntax-error-help-please/)
 * im trying to write a function and i keep getting a mysql sytax error.
    heres 
   the part that isnt working: ‘code’ $name = $wpdb->get_results(“SELECT (user_login)
   FROM $tableusers WHERE user_id = $id”); ‘code’ obviously its suposed to get a
   users login name from the wp_users table where the user_id is some number. i 
   have the global vaiables defined at the top like this: global $wpdb, $tableusers;
   so can someone rewrite that line for me?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [unoamigo](https://wordpress.org/support/users/unoamigo/)
 * (@unoamigo)
 * [21 years, 9 months ago](https://wordpress.org/support/topic/mysql-syntax-error-help-please/#post-70436)
 * What error are you getting?
    I believe you probably also want to use get_var(…)
   instead of get_results. get_results will return an array. (I’m pretty sure)
 *  Thread Starter [esgaroth](https://wordpress.org/support/users/esgaroth/)
 * (@esgaroth)
 * [21 years, 9 months ago](https://wordpress.org/support/topic/mysql-syntax-error-help-please/#post-70494)
 * i knew i was doing something dumb like that. thanks, it works now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘mysql syntax error, help please.’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [esgaroth](https://wordpress.org/support/users/esgaroth/)
 * Last activity: [21 years, 9 months ago](https://wordpress.org/support/topic/mysql-syntax-error-help-please/#post-70494)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
