Re: Segmentation fault error accrued when gcc -o test -L/usr/lib/mysql -lmysqlclient test.c

2006-07-24 Thread Chris White
On Sunday 23 July 2006 10:26 pm, ali asghar torabi parizy wrote:
> while ((row = mysql_fetch_row(res_set)) != NULL)  {

while (row = mysql_fetch_row(res_set))

would do the same thing, NULL check shouldn't be necessary.

>  for (i=0; i printf("%s\n",row[i] != NULL ? row[i] : "NULL");
>  }
> }
-- 
Chris White
PHP Programmer/DBanned!
Interfuel

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Segmentation fault error accrued when gcc -o test -L/usr/lib/mysql -lmysqlclient test.c

2006-07-23 Thread ali asghar torabi parizy

 
  hi to all.
 thanks luiz and mike for response.
my code is compiled when i use -lmysqlclient option and executable file is now 
exist but when i try to execute this file it prompts "Segmentation fault" 
.what's the meaning of it and what i have to do?
 ##
gcc -o test  -L/usr/lib/mysql -lmysqlclient test.c
 ##
The code is as fillows:
 
***
   
#include  
#include   
#define host "localhost"  
#define username "mysql"  
#define password ""  
#define database "test" 
MYSQL *conn; 
int main()  {  
conn = mysql_init(NULL); 
mysql_real_connect(conn,host,username,password,database,0,NULL,0); 
MYSQL_RES *res_set;  
MYSQL_ROW row;  
unsigned int i;  
mysql_query(conn,"SELECT * FROM users WHERE userid=1"); 
res_set = mysql_store_result(conn); 
unsigned int numrows = mysql_num_rows(res_set); 
while ((row = mysql_fetch_row(res_set)) != NULL)  {
 for (i=0; i<mysql_num_fields(res_set); i++)  { 
printf("%s\n",row[i] != NULL ? row[i] : "NULL");
 }  
}  
mysql_close(conn); 
return 0;  } 
*
Please help me


   
-
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail Beta.

 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

gcc -o test -L/usr/lib/mysql -lmysqlclient test.c

2006-07-23 Thread ali asghar torabi parizy
hi to all.
thanks luiz and mike for response.
my code  is compiled when i use -lmysqlclient option and executable file is now 
exist but when i try to execute this file it prompts "segmentation error" 
.what's the meaning of it and what i have to do?

The code is as fillows:
 
***
   
#include  
#include   
#define host "localhost"  
#define username "mysql"  
#define password ""  
#define database "test" 
MYSQL *conn; 
int main()  {  
conn = mysql_init(NULL); 
mysql_real_connect(conn,host,username,password,database,0,NULL,0); 
MYSQL_RES *res_set;  
MYSQL_ROW row;  
unsigned int i;  
mysql_query(conn,"SELECT * FROM users WHERE userid=1"); 
res_set = mysql_store_result(conn); 
unsigned int numrows = mysql_num_rows(res_set); 
while ((row = mysql_fetch_row(res_set)) != NULL)  {
 for (i=0; i