Welcome Guest, Not a member yet? Register   Sign In
echo field from db (mysql) when there is a space character in field name

Hello everyone,
I've got a DB transfered from Access and a field contains a space character in the field name (Why people do that, even in Access?)

so when i try to refer to this field:
if ($query->num_rows() > 0)
           $row = $query->row();
        echo $row->Home Address;

i am getting an error (seems normal).
How do i refer to this field in order to display it? quotes? any other characters? i played with it for a while but no luck (tried for example echo $row->'Home Address', doesn't work)

Hm.. after 14 hours in front of the screen my brain is probably somewhere else..

Instead of

$row = $query->row()
echo $row->Home Address

I used

$row = $query->row_array();
echo $row['Home Address'];

Seems to be working just fine.

This may presenst itself as a good time to update the database architecture too. Big Grin

I just "inherited" this Access db and i am pulling my hair, really. Field naming was (and still and issue).

E.g. (took me 4 hours to figure this out)

It's a Greek database and a field is named Occupation. All good? Well it's not good as the first character "O" is the Greek "O" and the rest goes latin. The guy found out that he's typing Greek and he said "Oops it's time to switch lang" without erasing the "O" character. How i found this? Only god knows heh Big Grin

Theme © iAndrew 2016 - Forum software by © MyBB