Depending on your exact requirements (which are slightly unclear), strtol() might not do what you need.
You start by saying:
>>How do I check if a string is an integer
and then later say:
>>how do I know whether Query string contains only integers
These are two different requirements.
To achieve the former, you would use strtol() as shown in the last link supplied by Dian.
To achieve the latter, strtol() will not necessarily work, as the data could be any number of bytes in length, and the content may well exceed the value an integer (int) can store (INT_MAX or UINT_MAX, limits.h). Therefore, the validation method would be to walk through the array checking each byte using isdigit() (ctype.h) to determine if it is a numeric. Using this method, you can test any number of bytes.