dongyipa0028 2014-02-05 05:06
浏览 51
已采纳

value没有插入数据库,代码没有错误

This is what I have done in my coding part. The code is free from errors but the values are not inserting

$name = $_POST['name'];
$cname = $_POST['cname'];
$caddr = $_POST['caddr'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$target_path = "upload/";
$target_path = $target_path.basename($_FILES['photo']['name']); 

move_uploaded_file($_FILES['photo']['tmp_name'], $target_path);
$str = "WEB";
$cnt = "SELECT COUNT(no) AS count FROM user";
$result = mysql_query($cnt);
$row = mysql_fetch_object($result);
$res = $row->count;
$res = $res+1;
$uid = $str.$res;
if($password==$cpassword) {
mysql_query("insert into user (no, uid, name, password, cpassword, photo) values('$res', '$uid', '$name', '$password', '$cpassword', '$target_path', now())");

}
  • 写回答

5条回答 默认 最新

  • duanmeng1862 2014-02-05 05:10
    关注

    please check you insert query , you have mentioned only 6 fields in insert statement but provided 7 values in insert statement. Updated query is below.

    mysql_query("insert into user (no,uid,name,password,cpassword,photo) values('".$res."','".$uid."','".$name."','".$password."','".$cpassword."','".$target_path."')");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器