Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This statement isn't returning a value.

char buffer[500]; sprintf(buffer, "SELECT COUNT(*) FROM tblURLIP WHERE IP = %s And IPStatus = '1' AndIPMax = '0'"), ipSrc, mysql_query(conn, buffer); 
Posted
Comments
Mohibur Rashid 6-Aug-11 3:36am    
I think you should re-consider about learning Programming. Seeing your code I am confident enough to say, you don't know programming.
Member 7766180 6-Aug-11 10:39am    
I think you should keep your nasty comments to yourself.

char buffer[500]; 
/* use sprintf - (s)tring(print)(f)ormatted */
/* wrap the %s for ipsrc in quotes */ 
sprintf(buffer, "SELECT COUNT(*) FROM tblURLIP WHERE IP = '%s' And IPStatus = '1' AndIPMax = '0'", ipSrc);
/* use the generated command */
mysql_query(conn, buffer);
 
Share this answer
 
Comments
Member 7766180 5-Aug-11 23:29pm    
YESSSSSSSSSS! It worked! You are so blessed!!!!!!!!!!
walterhevedeich 6-Aug-11 0:34am    
My 5.
Well, great. Did you consider using C++ instead of C for your string handling ? Did you consider checking what the SQL statement looks like and telling us what the resultant statement is ? Is it right that IP is not in quotes ? Have you done anything beyond writing some code and asking us to fix it for you ?
 
Share this answer
 
Comments
Member 7766180 5-Aug-11 21:55pm    
A lot of question but no answers, do you really think I just wrote it and posted it. So tired of being accused when I've been busting my a** all day long!!!! How about helping a novice out instead of the cocky statements!
Emilio Garavaglia 6-Aug-11 2:59am    
Actually Cristian has one point: you post is tagged as C++, but what you did is plain C. There are better standard ways to create and concatenate strings in C++ that don't suffer the memory allocation, based on std::string and std::sstream.
If you really want C (because you are required to do so), tag yoyr question as "C" (not C++), otherwise try to improve and understand the C++ way, instead to stay in "C compatibility mode".

Member 7766180 6-Aug-11 10:40am    
Thanks Emilio, being a novice I didn't know this was C. How would I write that in C++. I would appreciate an example.
Member 7766180 5-Aug-11 22:40pm    
I tried this and it doesn't compile.....
(mysql_query(conn,"SELECT COUNT(*) FROM tblURLIP WHERE IP = printf("%s",ipSrc) And IPStatus = '1' And IPMax = '0'"));

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