Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting these errors on a mySQL database hat is connected to the interent. Maybe the connection is timing out? Or it's in the code. Here are the Errors.

This is the error that pops up in a message box.
Unhandled exception at 0x57088ce4 in lsniff.exe: 0xC0000005: Access violation reading location 0x00000000


This is under the call stack when the app breaks
>russ.exe!main(int _argc=1, char * * _argv=0x00251bf8) 
Line 224 + 0x9 bytes C++ russ.exe!__tmainCRTStartup() 
Line 278 + 0x19 bytes C russ.exe!mainCRTStartup() 
Line 189 C – 


And this is next to the line in the code....
C++
res_set 0x00000000 {row_count=??? fields=??? data=??? ...}.


Here is the code.

C++
(mysql_real_connect(conn,"urlock.db.9873143.hostedresource.com"
,"Dk","Ad66","Dk",0,NULL,0) !=0);


char queryString[1024];
sprintf(queryString, "SELECT COUNT(*) FROM tblURLIP WHERE IP = '%s'
 AND IPStatus = '1' AND IPType = '3' AND IPMax ='0'", ipSrc == 0 ? "0" : ipSrc); 
mysql_query(conn, queryString);
my_ulonglong i = 0;
res_set = mysql_store_result(conn);
my_ulonglong numrows = mysql_num_rows(res_set);
LEGIT = mysql_fetch_row(res_set);
Posted
Updated 4-Oct-11 16:18pm
v2

1 solution

10 seconds with Google / Bing revealed: http://dev.mysql.com/doc/refman/5.0/en/mysql-store-result.html[^] which tells you that mysql_store_result() can return a NULL if an error occurred. It returned NULL, you tried to use a null result ---> BOOM.

That page also tells you where to look to see what the error was.
 
Share this answer
 
Comments
Member 7766180 4-Oct-11 20:32pm    
It was my understanding that if Count() found no records it would return a 0. However;ifit's returning an error, I guess that is a different story. Is there a way to make it return 0 on error as well? Thank you.
Chuck O'Toole 4-Oct-11 20:41pm    
Just because something returns a zero if there are no records, that does not absolve you from handling error conditions. The documentation clearly says that it will return a NULL on error. mysql_error() and/or mysql_errno() will tell you the reason. Write code to call those routines when you get the NULL and find out what error you are receiving. We could sit here all day and GUESS but you should go straight to authoritive source, the defined mysql API.
thepenguinmaster 7-Dec-11 17:01pm    
You know.. I hate when someone responds telling the person who asked how easy it would have been to just Google it. I Googled it, and got to this posting... I support the member for posting here.
Chuck O'Toole 7-Dec-11 20:23pm    
you know, I hate it when someone posts something without having any context first. Like the fact that the original poster has a long history of just dumping things into these forums without doing any research for themselves. At some point, you just have to tell them to lookup things themselves first. Learn how to fish. Of course, the "go google this" also included the relevant link for the answer. Thanks for playing.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900