duanhuiuw12555 2014-11-22 21:32
浏览 20

插入到SQL查询中的问题

$.ajax({
    url: 'http://localhost/xampp/htdocs/ajax.php',

    contentType: 'application/json',
    type: 'post',
    data: {

//score is a new variable and count2 is an integer variable which i want to send it to the database "score":"count2" },

    success: function () {
        alert("ok");

    },
    error: function () {
       alert("error");
    }
});    

The above code alerts me "ok".

function connect(){
    $connect = mysql_connect('localhost','root','') or die("ERROR");
    $connect2Database = mysql_select_db('fypdb', $connect);
    return $connect;
}

if(isset($_POST)){

    if($connect = connect()){

        $query = "INSERT INTO fypdbtable (score) VALUES ('".$_POST['score']."');";
        $completeQuery = mysql_query($query, $connect);
    }
}

I think the problem is on "insert into" query because in ajax.php prompts me Notice: Undefined index: score in C:\xampp\htdocs\xampp\htdocs\ajax.php on line 14 where it is the query line

Any help would be appreciate

  • 写回答

2条回答 默认 最新

  • dongniaocheng3773 2014-11-22 21:41
    关注

    The "error" message tells you, that $_POST['score'] is not defined. But thats just a warning. If you want to know if your variable is set, use isset() function or turn off warnings in the configuration.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题