segmentation fault in Mysql while deleting

From: sebi_peter(at)rediffmail(dot)com (sebi)
To: pgsql-general(at)postgresql(dot)org
Subject: segmentation fault in Mysql while deleting
Date: 2003-04-02 04:18:57
Message-ID: 825e589c.0304012018.435b82a0@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
>

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2003-04-02 07:25:13 Re: Slow query needs a kick in the pants.
Previous Message Jan Wieck 2003-04-02 03:51:44 Re: