Results 1 to 6 of 6

Thread: [RESOLVED] two times insert into doesn't work

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    right here
    Posts
    87

    Resolved [RESOLVED] two times insert into doesn't work

    Hello All,

    In my php pages I make a sql string:
    Code:
    INSERT INTO TBL_Magazijn_Locatie_Bezetting ( MagLocBezetId, MagLocId, Art_Ref_Fabr, Art_ArtSrt_Nr, Art_BCode, Art_Oms, Aant, txtDatum, Art_Nr, SerieNr )
    VALUES (3192, 415, 'DA150', 1, '� 33180', 'ONDERBOUWDAMPK MIELE 1M RVS', 1, '22/10/2009', '33180', '0');
    And php runs this sql string into the database, it works perfect.
    But when the user inserts the same product again it says 'saved' but it isn't saved into the msSQLserver database.
    No errors.
    When the user inserts another product it works perfect.
    When the user inserts the first product again it works perfect.
    It doesn't work with two times the same sql string.

    When I run the sql string in access it works, two times, twenty times.
    There is a column 'ID' which has a 'key' and 'autonumber' but this column isn't inserted. (as it shouldn't be)
    The value of Art_BCode--> '� 33180' is not the problem as I have removed the '�' and still it doesn't work two times after each other.

    The code is very long but this last bit is were the sql string is made and used.
    The code before this is all about filling the variables with the right information.


    if ($ErrorId == 0)
    {
    switch ($FO)
    {
    case 0:
    $Query_Insert = "INSERT INTO TBL_Magazijn_Locatie_Bezetting
    (MagLocBezetId, MagLocId, Art_Ref_Fabr, Art_ArtSrt_Nr, Art_BCode, Art_Oms, Aant, txtDatum, Art_Nr, SerieNr)
    VALUES ($MagLocBezetId, $MagLocId, '$Art_Ref_Fabr', 1, '$Art_BCode', '$Art_Oms', $Aantal, '$today', '$Art_Nr', '$SerieNr')";
    break;
    case 1:
    $Query_Insert = "INSERT INTO TBL_Magazijn_Locatie_Bezetting
    (MagLocBezetId, MagLocId, Art_Ref_Fabr, Art_ArtSrt_Nr, Art_BCode, Art_Oms, Aant, txtDatum, Art_Nr, Info_Srt, FactHfd_Nr, FactHfd_Klnt_Alias, FactHfd_Klnt_Naam, FactHfd_Klnt_Nr, FactHfd_Lev_Dat, SerieNr)
    VALUES ($MagLocBezetId, $MagLocId, '$Art_Ref_Fabr', 1, '$Art_BCode', '$Art_Oms', $Aantal, '$today', '$Art_Nr', '$Info_Srt', '$FactHfd_Nr', '$TMP_Klnt_Alias', '$TMP_Klnt_Naam', '$TMP_Klnt_Nr', '$TMP_Lev_Dat', '$SerieNr')";
    break;
    case 2:
    $Query_Insert = "INSERT INTO TBL_Magazijn_Locatie_Bezetting
    (MagLocBezetId, MagLocId, Art_Ref_Fabr, Art_ArtSrt_Nr, Art_BCode, Art_Oms, Aant, txtDatum, Art_Nr, Info_Srt, FactHfd_Nr, FactHfd_Klnt_Alias, FactHfd_Klnt_Naam, FactHfd_Klnt_Nr, FactHfd_Lev_Dat, SerieNr)
    VALUES ($MagLocBezetId, $MagLocId, '$Art_Ref_Fabr', 1, '$Art_BCode', '$Art_Oms', $Aantal, '$today', '$Art_Nr', '$Info_Srt', '$FactHfd_Nr', '$TMP_Klnt_Alias', '$TMP_Klnt_Naam', '$TMP_Klnt_Nr', '$TMP_Lev_Dat', '$SerieNr')";
    break;
    }

    //echo $Query_Insert;

    $result = odbc_do($connection, $Query_Insert);
    if ($result == true)
    {
    if (AantalAanpassen($MagLoc) == true)
    {
    echo "Is opgeslagen";
    }
    else
    {
    echo "Er is een fout opgetreden bij het opslaan in de functie AantalAanpassen()";
    }
    }
    else
    {
    echo "Er is een fout opgetreden bij het opslaan: " . $Query_Insert;
    }
    }

    odbc_close($connection);

    //______________________________________________________________________________
    //
    Thanks,
    Brian
    Last edited by brianbaart; Oct 22nd, 2009 at 04:49 AM. Reason: adding the 'save' php code. Brian
    If Not Now Then When

    If Not Here Then Where

Posting Permissions

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



Click Here to Expand Forum to Full Width