segmentation fault in Mysql while deleting - Mailing list pgsql-general

From sebi_peter@rediffmail.com (sebi)
Subject segmentation fault in Mysql while deleting
Date
Msg-id 825e589c.0304012018.435b82a0@posting.google.com
Whole thread Raw
List pgsql-general
hi there,
>it would be greatful if u help,i have been having this problem,i
am making a program in c and connecting the to database mysql
>the program is like this
>
>#include<stdlib.h>
>#include<stdio.h>
>#include "include/mysql.h"
>#include<string.h>
>
>
>MYSQL mysql;
>MYSQL_RES *res;
>MYSQL_ROW row;
>
>
>int ipdel()
>{
>char sql[]="delete from IPMaster where IP_Address ='" ;
>char ip1[25];
>char *ip;
>
>int temp;
>
>mysql_init(&mysql);
>if(mysql_real_connect(&mysql,"localhost","project","hi",NULL,0,NULL,0)==NULL)
>{
>printf("Can't connect to MySQL\n Reason :%s ",
>mysql_error(&mysql));
>}
>
>if(mysql_select_db(&mysql,"Status")!=0)
>{
>printf("Can't open the Database :%s",
>mysql_error(&mysql));
>}
>printf("Enter the IP Address to be Deleted :");
>scanf("%s",&ip1);
>ip=ip1;
>strcat(sql,ip);
>strcat(sql,"'");
>mysql_real_query(&mysql,sql,100);
>mysql_close(&mysql);
>
>return(0);
>}
>
>IP_Address is varchar(25) it is giving the segmentation fault
after it deletes the entry from the table. and program terminates.
it throws the SIGSEGV signal upon deletion could anybody help
how to avoid this segmentation fault
>
>when i am running gdb it gives the output
>
>Program received signal SIGSEGV, Segmentation fault.
>0x804a507 in main ()
>(gdb) where
>#0  0x804a507 in main ()
>Cannot access memory at address 0x27312e31
>(gdb) list
>1       rtld.c: No such file or directory.
>(gdb) c
>Continuing.
>
>Program terminated with signal SIGSEGV, Segmentation fault.
>The program no longer exists.
>


pgsql-general by date:

Previous
From: Vlad Krupin
Date:
Subject: 'DROP INDEX' kills stored rpocedures
Next
From: Pep
Date:
Subject: Anyone know of a news group for mysql?