Displaying content of SQL column

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Displaying content of SQL column

Post by snicolas »

Hi all,

I am encountering a small problem and wondering if this is normal or i am missing something.

I have a SQL db and run PHP 4.3
One of my Column name is quite Long, like "NumberOfLocationInTheBuilding"

If i try to echo this as echo &obj->NumberOfLocationInTheBuilding; nothing is displayed on my page.
But when I insert or update data via a php form, everyhting is loaded correctly in db.

So my question is:
Does echo have some restriction in the lenght of column name?

s
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

echo doesn't care how long the variable name is, nor does the computer. Post your code though.. &obj isn't valid code.
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Post by snicolas »

hey F

My code is simple
$obj_query = $sql->query("Select * from table where id='1'");
$obj= $sql->objects('',$obj_query);

From there I echo most of my table as:
exho $obj->name;
etc

most of column work apart from 3 column that are really long
their name are
NumberOfLocationInTheBuilding1
NumberOfLocationInTheBuilding2
NumberOfLocationInTheBuilding3

I quadruple checked the name and they are correct!

s
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check what gets output by var_export() and/or print_r() against $obj ...
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Post by snicolas »

Reducing the name of column "fixed" the problem...
Strange still, didn't know that a long column name could affect the display of results?

s
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it may only affect objects created by your functions.. using array's may be a better option.
Post Reply