| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		JBE -
 
  Joined: 05 Apr 2005 Posts: 1
 
  | 
		
			
				 Posted: Tue Apr 05, 2005 8:10 am    Post subject: CGI problems with query_string | 
				      | 
			 
			
				
  | 
			 
			
				Hi All
 
 
I have the following C++ CGI program (compiled with Borland Builder 6 and shown at the end of the message). The problem is that the query_string don't get transfer correctly to the program. 
 
 
When the program is called with: 
 
http://localhost/ctoolwww.exe?jb 
 
I get jb as a parameter (argc=1). However when the call is
 
http://localhost/ctoolwww.exe?jb=1
 
I don't get any parameter (argc=0). What am I doing wrong???
 
 
Any help with be greatly appriciated Jørgen
 
 
 
Program listning:
 
 
 
int main(int argc, char *argv[],char *env[]) {
 
 
   puts("Content-type: text/html\n");
 
   puts("<html><head><title>C-TOOL v6 </title></head>");
 
   puts("<body><form action=\"http://localhost/ctoolwww.exe\" method=get>");
 
   puts("<H1> Generelle bedrifts data </H1><br />");
 
   puts("JB nummer <select name=\"jb\">");
 
   puts("<p><input type=\"submit\" value=\"næste>\">");
 
   for (int i=0;i<10;i++)
 
      puts(argv[i]);
 
   char* qs = getenv("QUERY_STRING");
 
   if (qs)
 
      puts(qs);
 
   else
 
      puts("NULL ");
 
   puts("</body></html>");
 
   return 0;
 
} | 
			 
		  | 
	
	
		| Back to top | 
		
			          | 
		
	
	
		  | 
	
	
		aprelium -
 
  Joined: 22 Mar 2002 Posts: 6800
 
  | 
		
			
				 Posted: Tue Apr 05, 2005 12:42 pm    Post subject: Re: CGI problems with query_string | 
				      | 
			 
			
				
  | 
			 
			
				JBE,
 
 
The first URL is called an ISINDEX URL and its query string is passed in the QUERY_STRING environment variable and as an argument. It is a special case for query strings that do not contain the characters = or &.
 
 
It seems that the small test program doesn't work properly because you are asking it to display argv[i] for i ranging from 0 to 10. If the arguments count is not 10, this will lead to pointer problems and may crash the program or display non-sense.
 
 
Please replace 10 in the program with argc. We have tested it with this modification and it worked fine.
 
 
If the problem persists on your side, please send to support@aprelium.com your source code and your abyss.conf files. _________________ Support Team
 
Aprelium - http://www.aprelium.com | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		 |