SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy not able to insert data into database .!!

    please tell me why i am not able to insert data into database ..// what mistake i am doing please help me out

    PHP Code:
    <?php
    //var_dump($_POST);//use to see the all the possilbe value in the form of array with thier length..
    if(isset($_POST['clientname']))
    {
    $clientname             =$_POST['clientname']        ;
    $client_l_name          =$_POST['client_lname']        ;
    $client_pass             =$_POST['client_pass']        ;
    $client_con_pass        =$_POST['client_re_pass']    ;
    $client_client_phone    =$_POST['client_phone']        ;
    $client_mail            =$_POST['clientmail']        ;
    $client_date            =$_POST['user_date']        ;
    $client_month            =$_POST['month']            ;
    $client_year            =$_POST['year']                ;
    $client_gen                =$_POST['u_gen']            ;
    $client_sallary            =$_POST['sallary']            ;
    $client_pan                =$_POST['pancard']            ;
    $dbname                    ='form'                        ;
    $conn=mysql_connect("localhost","root","");
    if(!
    $conn)
    {
        die(
    'can nt connect to database').mysql_error();
    }
    $select_db=mysql_select_db($dbname,$conn);
    if(!
    $select_db)
    {
        die(
    'can nt select the database').mysql_error();
    }
    $insert_data="INSERT INTO user_info "."(
                    visitor_name,visitor_last_name,visitor_pass,visitor_conn_pass,visito
                    r_phone,visitor_mail,visitor_date,visitor_month,visitor_year,visitor_gender,vi          
                    sitor_sallary,visitor_pan,visitor_registration_date)"
    ."
                  VALUES"
    ."('$clientname','$client_l_name','$client_pass','$client_con_pass','client_client_phone','client_mail','client_date','client_month','client_year','client_gen','client_sallary','client_pan',NOW())";

    $sql_insert=mysql_query($insert_data,$conn).mysql_error();
    if(!
    $sql_insert)
    {
        die(
    'can nt insert data into database');
    }              
    else{
        echo 
    "thanku for feedback";
    }
    }
    Last edited by cpradio; Jun 20, 2013 at 06:35. Reason: Added php tags

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Have you turned on error reportng?
    2. what error message are you getting?
    3. have you tried echoing your query to ascertain it contains what you expect?

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    error reporting is On!
    no msg is getting ! yeah i echoing my query....sir still no response i got

  4. #4
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    666
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Any better?
    PHP Code:
    <?php
    //var_dump($_POST);//use to see the all the possilbe value in the form of array with thier length..
    if(isset($_POST['clientname']))
    {
        
    $clientname mysql_real_escape_string(trim($_POST['clientname']));
        
    $client_l_name mysql_real_escape_string(trim($_POST['client_lname']));
        
    $client_pass mysql_real_escape_string(trim($_POST['client_pass']));
        
    $client_con_pass mysql_real_escape_string(trim($_POST['client_re_pass']));
        
    $client_client_phone mysql_real_escape_string(trim($_POST['client_phone']));
        
    $client_mail mysql_real_escape_string(trim($_POST['clientmail']));
        
    $client_date mysql_real_escape_string(trim($_POST['user_date']));
        
    $client_month mysql_real_escape_string(trim($_POST['month']));
        
    $client_year mysql_real_escape_string(trim($_POST['year']));;
        
    $client_gen mysql_real_escape_string(trim($_POST['u_gen']));
        
    $client_sallary mysql_real_escape_string(trim($_POST['sallary']));
        
    $client_pan mysql_real_escape_string(trim($_POST['pancard']));
        
    $dbname ='form';
        
    $conn=mysql_connect("localhost","root","");
        if(!
    $conn)
        {
            die(
    'can nt connect to database').mysql_error();
        }
        
    $select_db=mysql_select_db($dbname,$conn);
        if(!
    $select_db)
        {
            die(
    'can nt select the database').mysql_error();
        }
        
    $insert_data="INSERT INTO user_info (visitor_name,visitor_last_name,visitor_pass,visitor_conn_pass,visitor_phone,visitor_mail,visitor_date,visitor_month,visitor_year,visitor_gender,visitor_sallary,visitor_pan,visitor_registration_date) 
                      VALUES('
    $clientname','$client_l_name','$client_pass','$client_con_pass','$client_client_phone','$client_mail','$client_date','$client_month','$client_year','$client_gen','$client_sallary','$client_pan',NOW())";
        
        
    $sql_insert=mysql_query($insert_data,$conn).mysql_error();
        if(!
    $sql_insert)
        {
            die(
    'can nt insert data into database');
        }              
        else{
            echo 
    "thanku for feedback";
        }
    }
    ?>


Bookmarks

Posting Permissions

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