From: Don Read <[EMAIL PROTECTED]>
> On 14-Jun-01 Kenneth Johansen wrote:
> > hi all, ive got a small problem (again).
> > i have a table with an entry "foo" which is an int(3).
> >
> > my problem is that whenever i collect the values in my c program.
> > they are returned as characters with mysql_fetch_row. (which is ok)
> > but i cant seem to convert them into int,
> > using something like
> >
> > temp = (int) row[0];
> >
> > this might not (strictly) be a mysql question.
> > but IMHO i dont think a C forum is the right place either.
> >
>
> No it's not; & yes, it would.

I disagree. This is the correct forum, as many MySQL users
have this problem.

To elaborate; MySQL returns *all* it's results as a text string, or more
specifically an array of text strings. This is actually a database standard
IIRC.

Just put them through either atoi (for integers), atol (for longs) or atoll
(for long longs).

It depends on the compiler and libraries, but these will generally work.

So what you need is :

temp = atoi(row[0]);

Which should work fine.

Russ.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to