I’m trying to get an organisation’s ID by giving its name.
I have the following code:
$orgid= $wpdb->get_var("SELECT organisationid FROM $wpdb->$table_name1 WHERE organisationname=' " . $organisation . "'");
This line returns this error:
Catchable fatal error:
Object of class wpdb could not be converted to string
I wish to echo this ID onto the page.
I have read the codex but do not understand. How can I fix this?
If you’re going to use variable variables inside the string, remember to wrap it with curly braces:
Note: Just make sure that the value of
$table_name1
does correspond to$wpdb
‘s properties of course so that it matches.Try also
instead of:
without dollar “$”