数据没有在mysql表中插入

时间:2017-02-02 10:10:57

标签: php mysql

<?php 
include 'dbh.php';
session_start();

if (isset($_GET['gmail'])) {
    $gname = $_GET['gmail'];
}

$gname = mysqli_real_escape_string($connect, $gname);
$_SESSION['myusername'] = $gname;

$today = date("d.m.y");

$k=0;

$sql = "SELECT cart_fext FROM cart WHERE cart_sess = '$sess'";
$result=mysqli_query($connect, $sql);

$kode[$k] = array();
$kame[$k] = array();
$kesc[$k] = array();
$kail[$k] = array();
$kid[$k] = array();
$kate[$k] = array();

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    extract($row);
    $k = $k + 1;
    $cname=$row['cart_item_name'];
    $csize=$row['item_size'];
    $cdesc=$row['cart_desc'];
    $cfpath=$row['cart_fpath'];
    $cfext=$row['cart_fext'];
    $ccode=$row['cart_itemcode'];
    $cuserid=$row['cart_usrid'];

    $kode[$k] = $ccode;
    $kame[$k] = $cname;
    $kesc[$k] = $cdesc;
    $kail[$k] = $gname;
    $kid[$k] = $cuserid;
    $kate[$k] = $today;
}

for($i=1; $i<=$k; $i++) { 

    $sqlsal = "INSERT INTO sales (s_code, s_name, s_desc, s_mail, s_userid, s_date) VALUES ('$kode[$i]', '$kame[$i]', '$kesc[$i]', '$kail[$i]', '$kid[$i]' ,'$kate[$i]')";
    $result=mysqli_query($connect, $sqlsal);

}
header("location:makedir.php");
?>

我的表销售只是不接受数据,dbh.php是连接数据库 我不明白这个剧本有什么问题? 请帮忙吗?

1 个答案:

答案 0 :(得分:0)

我已检查过您的插入查询它运行正常,但我认为问题出在您的SELECT查询

SELECT cart_fext FROM cart WHERE cart_sess = '$sess'

请打印查询结果。我认为它可能没有给出任何结果。