Re: Help! [No output from fcgi]
Patrick Lee <win32orphan-/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
thanks for the answer (i desperately need it).
here's my code:
-----------------------------------------------------
#include <stdio.h>
#include <mysql.h>
#include "flate.h"
#define host "localhost"
#define user "root"
#define pass "mypassword"
#define db "mydb"
void header(void);
int main(void)
{
MYSQL conn;
MYSQL_RES *result;
MYSQL_ROW row;
int i, nrows;
char sqlbuff[1024];
char strcontent[10240];
/* start fastcgi loop */
while (FCGI_Accept() >= 0) {
/* setting up template file */
templateSetFile("/home/lee/template/template.tpl");
if(mysql_init(&conn) == NULL) {
header();
printf("unable to initiate db
conn\n");
exit(0);
}
else {
if(mysql_real_connect(&conn,host,user,pass,db,0,NULL,0)
== NULL) {
header();
printf("unable to connect to
db!\n");
exit(0);
}
}
sprintf(sqlbuff, "SELECT * FROM `article`");
if(mysql_real_query(&conn,sqlbuff,strlen(sqlbuff))) {
header();
printf("db query failed!\n");
exit(0);
}
result = mysql_store_result(&conn);
nrows = mysql_num_rows(result);
header();
for(i=0; i<nrows; i++) {
row = mysql_fetch_row(result);
snprintf(strcontent, 1024, "<a href=\"%s\">article:
%s</a>", row[1], row[0]);
templateSetVar("article", strquickjump);
templateDumpTableLine("db");
}
mysql_free_result(result);
mysql_close(&conn);
/* printing out output to the template */
templatePrint();
} /* end of fastcgi while */
return 0;
}
void header(void)
{
printf("Content-type: text/html\n\n");
}
---------------------------------------------------
fastcgi version: fcgi-2.4.1-SNAP-0311112127
using Apache/1.3.27 Unix mod_perl/1.27 on Slackware
9.1
anyone here got any experience with template system
like flate ?
oh by the way, as i said before.. the code above
outputted things just as i expect on the console, but
not in web browser.
help desperately needed, thanks!
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/