sqlite+goahead+cgi

前端之家收集整理的这篇文章主要介绍了sqlite+goahead+cgi前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
void main()
{
printf("Content-type: text/html\r\n");
printf("\r\n");
printf("<html><head><title>CGI TEST</title></head>");
printf("<body>");
printf("<h1>BOA CGI TEST</h1>");
printf("<h2>huyi</h2>");
printf("Hello\n");
char *data;

long m,n;


//´òTMLͷ

printf("<title>Multiplication results</title>\n");

printf("<h3>Multiplication results</h3>\n");

data=getenv("QUERY_STRING");

//ȡµû·¾³±ä

if(data==NULL)

printf("<p>Error!Error in passing data to script");


else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)

printf("<P>Error! Invalid data. Data must be numeric.");

else

printf("<P>The product of %ld and %ld is %ld.",m,n,m*n);
sqlite3 *db =NULL;
char *zErrMsg = 0;

int rc;

rc = sqlite3_open("zieckey.db",&db);
if( rc )
{
fprintf(stderr,"Can't open database: %s\n",sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
else
printf("You have opened a sqlite3 database named zieckey.db successfully! \n");
char *sql ;

int nrow = 0,ncolumn = 0;
char **azResult;

sql = "SELECT * FROM SensorData ";
sqlite3_get_table( db,sql,&azResult,&nrow,&ncolumn,&zErrMsg );
int i = 0 ;
printf( "row:%d column=%d \n",nrow,ncolumn );
printf( "\nThe result of querying is : \n" );
for( i=0 ; i<( nrow + 1 ) * ncolumn ; i++ )
printf( "azResult[%d] = %s\n",i,azResult[i] );
sqlite3_free_table( azResult );

#ifdef _DEBUG_
printf("zErrMsg = %s \n",zErrMsg);
#endif

sqlite3_close(db);
return 0;

printf("</body></html>"); printf("\r\n"); printf("\r\n"); }

原文链接:https://www.f2er.com/sqlite/202579.html

猜你在找的Sqlite相关文章