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");
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值