Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mysql.h>
- #include <stdio.h>
- int main(void){
- MYSQL Connection;
- MYSQL_RES *res;
- MYSQL_ROW row;
- mysql_init(&Connection);
- if(mysql_real_connect(&Connection, "127.0.0.1", "root", "xururuca", "test", 0, NULL, 0)){
- printf("Connection: Ok...nn");
- }else{
- printf("Error in connectionnn");
- }
- mysql_query(&Connection ,"select id from accounts where username='Alan' and password='lixodoesgotogostoso';");
- res=mysql_store_result(&Connection);
- row=mysql_fetch_row(res);
- printf("%sn", row[0]); //ele imprime 3 (Ok...)
- int userID=row[0]; //Agora tento passar esse 3 para uma variável do tipo int...mais não rola
- printf("%dn", userID); //Imprime lixo e não 3 que seria o correto
- mysql_free_result(res);
- mysql_close(&Connection);
- return 0;
- }
Add Comment
Please, Sign In to add comment