sqlite+goahead+cgi

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

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

long m,n;

@H_403_1@ //´ò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");

@H_403_1@ 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);@H_403_1@ sqlite3 *db =NULL; @H_403_1@ char *zErrMsg = 0;

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

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

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

sqlite3_close(db); @H_403_1@ return 0;

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

猜你在找的Sqlite相关文章