1
add_data={"name":$("#name").val(), "smst":$("#smst option:selected").val(), "grade":$("#grade option:selected").val(), "score":$("#score option:selected").val(), "label":$("#label option:selected").val()};

        $.ajax({
            url: "add.php",
            type: "POST",
            data: add_data,
            contentType: 'charset=EUC-KR',
            dataType: "text",
            success: function(data){
                alert(data);
            },

it's ajax.

mysql_select_db("a");
$name=$_POST['name'];
$smst=$_POST['smst'];
$grade=$_POST['grade'];
$score=$_POST['score'];
$label=$_POST['label'];
$query="insert into calcul VALUES ('$name', '$smst','$grade','$score','$label');";
mysql_query($query);

it's php mysql

and when ajax excute, insert nothing to DB... someone help me! X(

sovovy
  • 21
  • 2
  • content type should be json.. – Drixson Oseña Nov 27 '15 at 03:22
  • Insert query needs fields and values - fields are missing `INSERT INTO calcul (fields) VALUES (values);`. Also, you are using depreciated `mysql` functions and you are vulnerable to injection attack see [Why shouldn't I use mysql_* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Tristan Nov 27 '15 at 03:24
  • dump $_POST to check if you get the values successfully – FelixHo Nov 27 '15 at 03:38

1 Answers1

0

Set contentType to 'application/x-www-form-urlencoded; charset=UTF-8' or remove it completely, because this is default value.

Ján Kyselica
  • 701
  • 5
  • 15