My problem:
In a WordPress site, I have a plugin which adds data to a table. The table has some columns whose names contain hyphens.
I don’t know if this is exactly my problem but it seem that my function breaks when I try to echo
the content of that field.
My function code:
function members_display() {
global $wpdb;
$sql = "SELECT text-529f61f42c30d AS name FROM wp_fm_data_5";
$results = $wpdb->get_results($sql) or die(mysql_error());
foreach ($results as $result) {
echo $result->name;
}
}
What i want to work is this:
function members_display() {
global $wpdb;
$sql = "SELECT * FROM wp_fm_data_5";
$results = $wpdb->get_results($sql) or die(mysql_error());
foreach ($results as $result) {
echo $result->[text-529f61f42c30d];
}
}
How can I resolve this issue?
Try to surround the column name with
`. (Backtick)