0
public function getSiteValues($value) {
    $this->db->select(
        'site', 
        'id, option_name, option_value', 
        NULL, 
        'option_name=' . $value
    ); // database, what to take, where value 
    $res = $this->db->getResult();

    echo '<pre>';
    print_r($res);
    echo '</pre>';
}

In this case I would like to put for example:

getSiteValues('sitename')

and so that this would return the value of sitename row and from option_value column, but it keep giving me error such as

[0] => Unknown column 'sitename' in 'where clause'

What can I do to fix this?

PS. I have tried to look at other solutions but they have keep giving me wrong solutions. I have tried most of them. btw I am using this crud library - https://github.com/rorystandley/MySQL-CRUD-PHP-OOP for db connections

alex
  • 23
  • 2
  • Can you give us the result of SHOW CREATE TABLE My_Table\G where the table concerned contains the field 'sitename'. – Vérace Jun 12 '15 at 12:50

1 Answers1

0

Sitename is a string, but you're not enclosing it in apostrophes, so SQL is interpreting it as a column. Please try adjusting like so:

"option_name='" . $value . "'"

Nicholai
  • 383
  • 1
  • 11