Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2003
    Posts
    4

    Wink Unanswered: help me pllllzzzzz

    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
    Last edited by sebi_peter; 03-27-03 at 03:33.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •