game-game 0 Report post Posted October 2, 2007 Hye rakan-rakan..ader sape-sape tau macam mane nak connect socket programming ngan database, ie mysql, tak?aku dah cari dalam google, still takde.. bleh tunjuk tak camner nak buat? at least untuk login pon jadi r, pastu aku blajar sndri.. aku tak nmpak n takde idea camne nak start..thanks.. Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted October 2, 2007 kalau ko baca manual mysql, memang dia dah sediakan library utk connect ke mysql server melalui tcp/ip connection.http://dev.mysql.com/doc/refman/5.0/en/mys...al-connect.html Quote Share this post Link to post Share on other sites
game-game 0 Report post Posted October 4, 2007 ek.. aku dah blajar sket2 pasal socket ngan mysql, aku cube compile ngan cara camni1. gcc -c -I/usr/include/mysql connect1.c2. gcc -o connect1 connect1.o -L/usr/include/mysql -lmysqlclient3 ./connect1tapi aku dapat segmentation fault pas aku cube run file kat bawah ni dengan name connect1.ckenape ek?#include <my_global.h> #include <my_sys.h> #include <mysql.h> static char *opt_host_name = NULL; // server host (defaul t= localhost) static char *opt_user_name = NULL; // username (default = login name) static char *opt_password = NULL; // password (default = none) static unsigned int opt_port_num = 0; // port number (use built-in value) static char *opt_socket_name = NULL; // socket name (use built-in value) static char *opt_db_name = NULL; // database name (default = none) static unsigned int opt_flags = 0; // connection flags(none) static MYSQL *conn; int main (int argc, char *argv[]) { //initialize connection handler conn = mysql_init (NULL); if (conn = NULL) { fprintf(stderr, "mysql_init() failed (probably out of memory)\n"); exit(1); } //connect to server if (mysql_real_connect (conn,opt_host_name, opt_user_name, opt_password,opt_db_name, opt_port_num, opt_socket_name, opt_flags) == NULL) { fprintf(stderr, "mysql_real_connect() failed\n"); mysql_close (conn); exit(1); } //disconnect from server mysql_close (conn); exit(0); } Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted October 4, 2007 maybe u want to use 127.0.0.1 instead localhost Quote Share this post Link to post Share on other sites