Hi! I am trying to insert the data froma a form into 3 tables. Although I get no errors only the first insert works. Could you please help me and tell me what am I doing wrong?

$query_add = "insert into autoturisme values('', '$producator', '$model', '$categorie', '$nume_poza', '$motor', '$consum', '$locuri', '$capacitate', '$tip', '$transmisie', '1', '1', '$km', '$data_revizie', '$comentarii')";

mysql_query($query_add) or die("Problema Add auto: ".mysql_error());

    //insert into table facilitati
    if(isset($_POST['aer_conditionat']) && $_POST['aer_conditionat'] == '1') 
            { $ac=1;}
        else {$ac=0;}
    if(isset($_POST['inchidere_centralizata']) && $_POST['inchidere_centralizata'] == '1') 
            { $ic=1;}
        else {$ic=0;}
    if(isset($_POST['geamuri_electrice']) && $_POST['geamuri_electrice'] == '1') 
            { $ge=1;}
        else {$ge=0;}
    if(isset($_POST['alarma']) && $_POST['alarma'] == '1') 
            { $a=1;}
        else {$a=0;}
    if(isset($_POST['servo_directie']) && $_POST['servo_directie'] == '1') 
            { $sd=1;}
        else {$sd=0;}
    if(isset($_POST['cd_player']) && $_POST['cd_player'] == '1') 
            { $cd=1;}
        else {$cd=0;}
    if(isset($_POST['airbag']) && $_POST['airbag'] == '1') 
            { $air=1;}
        else {$air=0;}
    if(isset($_POST['priza']) && $_POST['priza'] == '1') 
            { $p=1;}
        else {$p=0;}
    if(isset($_POST['abs']) && $_POST['abs'] == '1') 
            { $abs=1;}
        else {$abs=0;}

    $query_add_facilitati="insert into facilitati values('$id', '$ac', '$ic', '$ge', '$a', '$sd', '$cd', '$air', '$p', '$abs')";

    mysql_querry($querry_add_facilitati) or die("Problema Add in tabela facilitati ".mysql_error()); 

    //insert into  tabel tarife
        $t_1_3      = $_POST['1_3_zile'];
        $t_4_7      = $_POST['4_7_zile'];
        $t_8_14     = $_POST['8_14_zile'];
        $t_15_21    = $_POST['15_21_zile'];
        $t_p_21     = $_POST['peste_21_zile'];
        $query_add_tarife = "insert into tarife values('$id','$t_1_3','$t_4_7','$t_8_14','$t_15_21','$t_p_21')";
        mysql_query($query_add_tarife) or die("Eroare inserare in tabela tarife:".mysql_error());

Edited by mike_2000_17: Fixed formatting

7 Years
Discussion Span
Last Post by urtrivedi

You echo query on screen copy it and try to run in mysql directly may be on mysql command prompt or phpmyadmin. Check whether your query works directly to backend or not. keep echo statment before calling mysql_query() function.

echo $query_add_tarife."<br>";

echo $query_add_facilitati."<br>";

Edited by urtrivedi: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.