1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <time.h>
#include <winsock.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <fstream>
#include <mysql.h>
#include <MYSQL/mysql.h>
using namespace std;
int main()
{
char requete[100];
char chaine1[100];
FILE*fich;
fich=fopen("C:\\Users\\pac\\Desktop\\coco.txt","r");
fgets(chaine1,100,fich);
MYSQL mysql;
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"mysql_test1");
if(mysql_real_connect(&mysql,"**.fr.mysql","user","mot de passe","BDD",3306,NULL,0)==NULL){
sprintf(requete, "INSERT INTO boite VALUES('', '%s')",chaine1);//boite=table dans ma BDD
mysql_query(&mysql, requete);
mysql_close(&mysql);cout<<"ca marche pas"<<endl;
}
else{cout<<"ca marche"<<endl;}
} |
Partager