加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite+goahead+cgi

发布时间:2020-12-12 20:42:39 所属栏目:百科 来源:网络整理
导读:#include stdio.h #include stdlib.h #include "sqlite3.h" void main() { printf("Content-type: text/htmlrn"); printf("rn"); printf("htmlheadtitleCGI TEST/title/head"); printf("body"); printf("h1BOA CGI TEST/h1"); printf("h2huyi/h2"); prin

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

long m,n;


//′òTML?

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

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

data=getenv("QUERY_STRING");

//?μ?·?3±?

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: %sn",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] = %sn",i,azResult[i] );
sqlite3_free_table( azResult );

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

sqlite3_close(db);
return 0;

printf("</body></html>"); printf("rn"); printf("rn"); }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读