PDOException "column not found" but does exist
Concatenating variables into an SQL query is usually a bad idea (search for SQL injection and you'll see why). The D6 version you're starting with:

$result = db_result(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable));


uses parameters, you just need to convert that to use the newer query substitution in D7. The docs for db_query() have some good examples, essentially what you need for this particular query is:

$query = 'SELECT value FROM {variable} WHERE name = :name';
$params = array(':name' =&gt; $variable);
$result = db_query($query, $params)-&gt;fetchField();