Click here to Skip to main content
14,328,926 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have an online MYSQL database with one table and 5 fields.
ID      int
IP      varchar
URL     varchar
UDC     varhar
Status  enum


When I do a query on this, it is returning either 1 row or 0 rows only it seems to be coming back as a ulonglong data type.
What would be causing this, can I get it to return an int?

DS
Posted
Updated 13-May-11 11:57am
v5
Comments
Member 7766180 12-May-11 23:40pm
   
IP is an IP address. I have the field length set to 15 but its truncating it. I put in let say 192.168.1.1 and I get 192168 back. This might be the culpurt?
Debojyoti Majumder 13-May-11 1:00am
   
can you share your code?
Member 7766180 13-May-11 10:52am
   
int main()
{
MYSQL_RES *res_set;
MYSQL* conn;
MYSQL_ROW row;



conn = mysql_init(NULL);
if (mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","VendorCheck","Reader1234","urlock",0,NULL,0) !=0)
{
mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = '192.168.1.33' AND Status = 'Active'");
int i = 0;
res_set = mysql_store_result(conn);
int numrows = mysql_num_rows(res_set);
{
row = mysql_fetch_row(res_set);
/*If Statement In Here*/
}
{
if (int(row[i]) >= 1)
printf("PASS: %s\n",row[i]);
else
printf("FAIL: %s\n",row[i]);
}

mysql_free_result(res_set);
mysql_close(conn);
system("PAUSE");
}
else
{
cout << "Conn Failed!" <<endl;
system("PAUSE");
return 0;
}
}
Member 7766180 13-May-11 10:58am
   
This is the error I'm getting on debug.
warning C4244: 'initializing' : conversion from 'my_ulonglong' to 'int', possible loss of data
Albert Holguin 13-May-11 11:19am
   
we went over this... :)
Member 7766180 13-May-11 17:56pm
   
Warnng gone! This returns "PASS" whether i="1" or "0"...
the [i] is returning a row count, thats for sure...whenever I maipulate the data, I get exactly what I expect. It's just this darn "PASS" "FAIL" thing that is driving "US" crazy!!! ;)

int main()
{
MYSQL_RES *res_set;
MYSQL* conn;
MYSQL_ROW RED;

conn = mysql_init(NULL);
if (mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","VendorCheck","Reader1234","urlock",0,NULL,0) !=0)
{
mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = '192.168.1.33' AND Status = 'Active'");
my_ulonglong i = 0;
res_set = mysql_store_result(conn);
my_ulonglong numrows = mysql_num_rows(res_set);

RED = mysql_fetch_row(res_set);

if (my_ulonglong (RED[i]) >= (my_ulonglong)1)
printf("PASS: %s\n",RED[i]);
else
printf("FAIL: %s\n",RED[i]);
mysql_free_result(res_set);
mysql_close(conn);
system("PAUSE");
}
else
{
cout << "Conn Failed!" <<endl;
system("PAUSE");
return 0;
}
}

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You are basically reposting the same question again and again and ignoring all the advice and suggestions that have been offered. If you have some updated information then add it to the original question.
   
Comments
Albert Holguin 13-May-11 10:20am
   
lol, I like how this guy bothers you so much, yet you just have to post something every time.
Richard MacCutchan 13-May-11 11:00am
   
Come on, read through his latest questions, they are all the same thing. And he refuses to go and look at the documentation (which I provided a link for) or to listen to what other contributors have offered in the way of help.
Albert Holguin 13-May-11 11:16am
   
This is getting bad, but still... no one's forcing you to read his posts... or me for that matter... :)
Richard MacCutchan 13-May-11 13:04pm
   
I am actually trying to help him. The trouble is that you and Kode King are just adding clutter and noise.
Albert Holguin 13-May-11 13:16pm
   
I can't hear you over the noise! ...Speak up! :p ...but seriously, you post mean things quite often, look through your answers and lets see what the ratio is from actual solutions to noise that you're adding.
Richard MacCutchan 14-May-11 4:01am
   
You're beginning to sound like a broken record. I think you two should start a new forum.
Kode King 13-May-11 10:55am
   
Hey Richard, Since you aren't contributing, maybe you can keep count!
Richard MacCutchan 13-May-11 10:58am
   
I'm contributing a damn sight more than you. I have at least made the effort to go and read the documentation and provide a link and an explanation which will help resolve his issue. All you have done is post stupid remarks.
Kode King 13-May-11 11:08am
   
Your only contribution has been meanness and confusion.
Albert Holguin 13-May-11 11:18am
   
he did contribute a nice link earlier... but there's a lot of grumpy people in the site... something you have to deal with if you ask bad questions... it is what it is I guess
Kode King 13-May-11 11:46am
   
Yes Albert. You are right, one link. Grumpy is right! I've only just joined this site and it seems to me that you are the calm in the storm here. Apparently this person is new, and is having difficulty. If I knew the answer I would post it! I wish someone would please post the answer (in code) and put Richard and the Poster out of their misery! :) :) ;)
Albert Holguin 13-May-11 11:48am
   
lol, unfortunately the poster has had A LOT of problems... he's new to C++ and SQL (it seems)
Member 7766180 13-May-11 11:54am
   
Hey Albert, you right! Remember a while back you said that I was in over my head? I was and I still am! But I am more than willing to learn. With your kindness and help of a few other nice people I've been able to come pretty close to finishing this. I love learning. And will continue to learn, even if this is a "BEAR" to get through. Once again Thank You.
DS
Albert Holguin 13-May-11 11:57am
   
I'll continue to help when I can... like I said, its been ages since SQL, so I don't even know if your queries are correct or not...
Member 7766180 13-May-11 12:11pm
   
Thank You. It seems that mysql_fetch_row returns the answer as a my_ulonglong. Perhaps mysql_fetch_row isn't the way to go? But in any case isn't my_ulonglong a number? I tried changing the 1 to '1', "1" and 1. Still getting the warning, I'm not to worried about the warning, just wnat the result.
Albert Holguin 13-May-11 11:50am
   
...and I'm only as calm as the picture in my profile... :D
Member 7766180 14-May-11 11:36am
   
Albert. OriginalGriff did it!
if (atoi(RED[i]) == 1)
This made it work!
We can all sleep better now! LOL!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100