55 users online (1 members and 54 guests)  


  Results 1 to 4 of 4

Related

  1. Call Method    Forum: CGI Perl Forum
    Replies: 0
  2. submit() method error    Forum: Javascript Forum
    Replies: 0
  1. #1
    C05MIN's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2005
    Posts
    2

    method problem ?

    Hi.
    Why the code works only for the print instruction ?– I mean it shows on the screen the results—but in the data bases it only records, the first row of values.
    What method do I have to use ?
    The data for this script are sent to it by a post action
    PLEASE HELP ME !!!

    <?
    include ("conectare.php");
    $i=1;$z=5;
    while($i<=$z)
    {
    $id_produs = "id_produs"."$i";
    $id_unitate = "id_unitate"."$i";
    $cantitatea = "cantitatea"."$i";
    $pret_unitar = "pret_unitar"."$i";

    $factura = 55;//$_POST['nr_generare'];
    $var = $_POST[$id_produs];
    $var1 = $_POST[$id_unitate];
    $var2 = $_POST[$cantitatea];
    $var3 = $_POST[$pret_unitar];

    print "$var";
    print "$var1";
    print "$var2";
    print "$var3"."<br>";


    $sql = "insert into produse values ($factura,$var,$var1,$var2,$var3)";
    mysql_query($sql);



    $i++;
    }

    after that i tried this ....
    .......................
    $sql = "insert into produse (id_a,id_b,id_c,id_d,id_e) values ($factura, $var,$var1,$var2,$var3)"

    mysql_query($sql) or die("insert error:".mysql_query());

    this just stop the code after it runs once.

    What do i have to change ?

    Thanks.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    First, we need to see the mySQL errors.

    change mysql_query($sql); line to

    Code:
    if (!$result = mysql_query($sql)) {
    echo mysql_error();
    }
    Amd see what it says.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    C05MIN's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2005
    Posts
    2

    Done. :)

    Thanks !!!!!!!!!!!!!!!!
    From 4 forums you are the only person that gave me an answer.
    Thanks very much. The best people in the best forum .

    Back to the problem. I don’t now haw, but I never stop trying to solve the problem :P,and I put in some extra variables to make the sum of the string for the sql command ….and like 10 minutes ago it worked perfectly.

    Thanks allot for your answer and specially your time !!!!!

    Bye bye,
    Paul Cosmin.

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    No Worries Paul.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread