The Open Source Swiss Army Knife

/sql_servers/mysql/mysql_c/
/sql_servers/mysql/mysql_c/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /sql_servers   /mysql   /mysql_c 
Permalink: testd.c
Title: add
article options : please login   |  raw source view  

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mysql.h"

#define MYSQL_HOST   "localhost"       // database server name
#define MYSQL_DB     "test"        // database name
#define MYSQL_USERID "testuser"          // database user id
#define MYSQL_PASSWD "testpass"        // userid password
#define MYSQL_TABLE  "pets"          // table name

#define PROGRAM_HEADER "<H1>MySQL C-API Example Query Results</H1>\n"

// This is not the best or safest way to process field forms in C since
// sscanf is unsage.  It is used here only to simplify the example

void GetFormField(char *value) {

  char *data;

  data = "name=joe";
  /*  data = getenv("QUERY_STRING"); */

  if(data == NULL) {
    strcpy(value,"");
    return;
  }

  // make sure data does not exceed maximum length
  if (strlen(data) > 20) {
    strcpy(value,"");
    return;
  }
/*  input is read from data, nu of matches returned   */
  if (sscanf(data,"name=%s",value) != 1) {
    strcpy(value,"");
  }

}

int main() {
	char * vale;
	GetFormField(vale);
	printf("%s\n",vale);
}

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top