无法将数据添加到数据库

时间:2017-11-16 08:46:49

标签: php html pastebin

我试图通过我创建的表单将数据添加到数据库,但我似乎无法让它工作。谁能帮帮我吗?

我已经包含了一些代码,我认为这是问题,但也包含了所有代码的pastbin链接。

https://pastebin.com/PpfCvjhf

$user_id = $_POST['user_id'];
            $grafik_name = $_POST['grafik_name'];
            $grafik_coin = $_POST['grafik_coin'];
            $grafik_hashrate = $_POST['grafik_hashrate'];
            $grafik_bios_mod = $_POST['grafik_bios_mod'];
            $grafik_core_clock = $_POST['grafik_core_clock'];
            $grafik_memory_clock = $_POST['grafik_memory_clock'];
            $grafik_power_draw = $_POST['grafik_power_draw'];
            $grafik_additional_info = $_POST['grafik_additional_info'];

            
            $sql = "INSERT INTO `cards` (`id`, `name`, `coin`, `hashrate`, `bios_mod`, `core_clock`, `memory_clock`, `power_draw`, `additional_info`) VALUES ('$user_id','$grafik_name','$grafik_coin','$grafik_hashrate','$grafik_bios_mod','$grafik_core_clock','$grafik_memory_clock','$grafik_power_draw','$grafik_additional_info', NOW())";
               
            mysql_select_db('grafik');
            $retval = mysql_query( $sql, $conn );

<?php

https://pastebin.com/PpfCvjhf

2 个答案:

答案 0 :(得分:0)

此查询出错:

$sql = "INSERT INTO `cards` (`id`, `name`, `coin`, `hashrate`, `bios_mod`, `core_clock`, `memory_clock`, `power_draw`, `additional_info`) VALUES ('$user_id','$grafik_name','$grafik_coin','$grafik_hashrate','$grafik_bios_mod','$grafik_core_clock','$grafik_memory_clock','$grafik_power_draw','$grafik_additional_info', NOW())";

列数少于值!!

答案 1 :(得分:0)

  1. 列数与值不匹配。 问题是:NOW())仔细看看。删除NOW())

  2. 您的查询我认为错了。 正确的是$sql = "INSERT INTO table_name (column1, column2) VALUES ('$values1', '$values2')";