vendredi 24 juin 2016

INSERT excecuted multiple times

I'm writing a script that insert into a table a record, it's executed multiple time while I'm writing it only once! I'm using WAMP server and MySQL database.

This is my script:

   <?php
$dbc= mysqli_connect('localhost', 'root', '', 'aliendatabase')
        or die('Error connecting to MySQL server.');

    $query= "
    INSERT INTO aliens_abduction( first_name
                                , last_name
                                , when_it_happened
                                , how_long
                                , how_many
                                , alien_descripition
                                , what_they_did
                                , fang_spotted
                                , other
                                , email
                                ) VALUES 
                                ( 'Sally'
                                , 'Jones'
                                , '3 days ago'
                                , '1 day'
                                , 'four'
                                , 'green with six tentacles'
                                , 'We just talked and play with a dog'
                                , 'yes'
                                , 'I may have seen your dog. Contact me.'
                                , 'sally@gregs-list.net');
    ";

    $result= mysqli_query($dbc, $query)
        or die ('Error querying database.');

    mysqli_close($dbc);
?>

I rewrite this script alone in a notepad++ file to test it but the same problem appear. Each time I execute this code, it add the same record multiple time: 3 or 4 or 5. Someone told me to insert a trigger but I'm a beginner in SQL and I don't know if a trigger will do the job in my case.

Aucun commentaire:

Enregistrer un commentaire