Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Query retrieving data as number when data type is a varchar with text
Old 07-03-2008, 06:49 AM Query retrieving data as number when data type is a varchar with text
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
I have a field in my people table called 'client' and it stores a text string using varchar. But when I get the data from the table and print it using PHP it prints the number 1 for every record, but for all of the other data retrieved for the other fields in the same record it prints out the correct data.

For example, this is the query I am using:

PHP Code:
$peopleIds =& $db->query("SELECT * FROM people P, organisation O, organisationPeople OP WHERE P.personId = OP.personId AND O.organisationId = OP.organisationId AND OP.organisationId = '$_GET[id]' ORDER BY P.first_name ASC");
        
checkDBError($peopleIds);
 
while(
$peopleIds->fetchInto($peopleId))
    {
          
$peopleId['firstName']; // Prints the first name
          
$peopleId['client']; // Prints 1 for every record
    

Any ideas?

Thanks,
drew22299 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-03-2008, 06:53 AM Re: Query retrieving data as number when data type is a varchar with text
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
I fixed this by changing the name of the client field to ISclient and it now displays the data stored for that field. I'm guessing client is a reserved word in MySQL?
drew22299 is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 08:40 AM Re: Query retrieving data as number when data type is a varchar with text
Skilled Talker

Posts: 94
Trades: 0
No, but here is a great link to check in the future

http://dev.mysql.com/doc/refman/5.0/...ved-words.html
__________________
Sell Templates? Try our
Please login or register to view this content. Registration is FREE
! See a live
Please login or register to view this content. Registration is FREE
ChadR is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 08:42 AM Re: Query retrieving data as number when data type is a varchar with text
Skilled Talker

Posts: 94
Trades: 0
Maybe a type-0?

organisation

organization

I know I am American and we have a funny way of spelling so maybe it's different there.
__________________
Sell Templates? Try our
Please login or register to view this content. Registration is FREE
! See a live
Please login or register to view this content. Registration is FREE
ChadR is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 08:54 AM Re: Query retrieving data as number when data type is a varchar with text
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
Thanks for the link CharR, I didn't come accross that one I don't think it's the spelling of the word organisation because it prints out the data from that field as long as it's not called action I had a similar problem a few weeks ago when I called a field phone and then changed it to phoneNum and it worked lol maybe it's something to do with how the server is setup?
drew22299 is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 05:40 PM Re: Query retrieving data as number when data type is a varchar with text
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I'd suggest that "client" could have been an ambiguous field name because of the use of * instead of a fieldlist.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-04-2008, 09:00 AM Re: Query retrieving data as number when data type is a varchar with text
Skilled Talker

Posts: 94
Trades: 0
Quote:
Originally Posted by chrishirst View Post
I'd suggest that "client" could have been an ambiguous field name because of the use of * instead of a fieldlist.

Chris is probably right, if you had 2 or more tables with the "client" column in it then that would happen. Using SELECT * is almost always a bad idea.
__________________
Sell Templates? Try our
Please login or register to view this content. Registration is FREE
! See a live
Please login or register to view this content. Registration is FREE
ChadR is offline
Reply With Quote
View Public Profile
 
Old 07-07-2008, 07:02 AM Re: Query retrieving data as number when data type is a varchar with text
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
chrishirst, ChadR the query did have SELECT * Thanks for your comments, I didn't know that using SELECT * could make problems

Last edited by drew22299; 07-07-2008 at 07:05 AM..
drew22299 is offline
Reply With Quote
View Public Profile
 
Old 07-07-2008, 08:05 PM Re: Query retrieving data as number when data type is a varchar with text
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Select * is nothing but problems!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Query retrieving data as number when data type is a varchar with text
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27270 seconds with 12 queries