Rumah >pembangunan bahagian belakang >tutorial php >大家帮忙找下问题所在 我实在看不出来
$sql_insert = "insert into tb_user (usernc,turename,pwd,email,sex,tel,qq,address,logintimes,regtime,lastlogintime,ip,yb,usertype,question,answer,truepwd,photo,score) values('$_POST[usernc]','$_POST[truename]','" . md5($psw) . "','$_POST[email]','$_POST[select]','$_POST[tel]','$_POST[qq]','$_POST[address]','0','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','" . $_SERVER['REMOTE_ADDR'] . "',' $_POST[yb]','0','$_POST[question]','$_POST[answer]','$_POST[truepwd]','$_POST[photo];','30')";
$res_insert = mysql_query($sql_insert);
//$num_insert = mysql_num_rows($res_insert);
if($res_insert)
{
echo "<script>alert('注册成功!'); history.go(-1);</script>";
}
else
{
echo "<script>alert('系统繁忙,请稍候!!!'); history.go(-1);</script>";
}
信息填完点注册只能跳转到系统繁忙,我觉得是自己的sql语句有问题 但找不出来
{
echo "<script>alert('系统繁忙,请稍候!!!'); history.go(-1);</script>";
}
改为
{
$msg = mysql_error();
echo "<script>alert('$msg'); history.go(-1);</script>";
}
看看弹出框中是什么
弹不出来 直接空白的
$sql_insert = "insert into tb_user (usernc,turename,pwd,email,sex,tel,qq,address,logintimes,regtime,lastlogintime,ip,yb,usertype,question,answer,truepwd,photo,score) values('$_POST[usernc]','$_POST[truename]','" . md5($psw) . "','$_POST[email]','$_POST[select]','$_POST[tel]','$_POST[qq]','$_POST[address]','0','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','" . $_SERVER['REMOTE_ADDR'] . "',' $_POST[yb]','0','$_POST[question]','$_POST[answer]','$_POST[truepwd]','$_POST[photo] ;','30')";
套红处???
额 去了也不行
如果是 sql 指令错误,mysql 是会给你提示的
你不看,怎么行?
$msg = mysql_error();
echo "<script>alert('$msg'); history.go(-1);</script>";
这局加过了 是弹不出来信息
直接显示空白的话,就说明你的程序有语法错误,且错误显示功能没有打开
你只给了程序片段,无法判断问题的所在
require_once 'conn.php';
if(isset($_POST["submit"]) && $_POST["submit"] == "注册")
{
$user = $_POST["usernc"];
$trueuser=$_POST["truename"];
$psw = $_POST["pwd"];
$psw_truepwd = $_POST["truepwd"];
$email = $_POST["email"];
$sex = $_POST["select"];
$tel = $_POST["tel"];
$qq = $_POST["qq"];
$address = $_POST["address"];
$yb = $_POST["yb"];
$question = $_POST["question"];
$answer = $_POST["answer"];
$photo= $_POST["photo"];
if($user == "" || $trueuser == ""|| $psw == ""|| $psw_truepwd == ""|| $email == ""|| $sex == ""|| $tel == ""|| $qq == ""|| $address == ""|| $yb == ""|| $question == ""|| $photo == ""|| $answer == "")
{
echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
}
else
{
if($psw == $psw_truepwd)
{
$sql = "select usernc from tb_user where usernc = '$_POST[usernc]'"; //SQL语句
$result = mysql_query($sql); //执行SQL语句
$num = mysql_num_rows($result); //统计执行结果影响的行数
if($num) //如果已经存在该用户
{
echo "<script>alert('用户名已存在'); history.go(-1);</script>";
}
else //不存在当前注册用户名称
{
$sql_insert = "insert into tb_user (usernc,turename,pwd,email,sex,tel,qq,address,logintimes,regtime,lastlogintime,ip,yb,usertype,question,answer,truepwd,photo,score) values('$_POST[usernc]','$_POST[truename]','" . md5($psw) . "','$_POST[email]','$_POST[select]','$_POST[tel]','$_POST[qq]','$_POST[address]','0','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','" . $_SERVER['REMOTE_ADDR'] . "',' $_POST[yb]','0','$_POST[question]','$_POST[answer]','$_POST[truepwd]','$_POST[photo]','30')";
$res_insert = mysql_query($sql_insert);
//$num_insert = mysql_num_rows($res_insert);
if($res_insert)
{
echo "<script>alert('注册成功!'); history.go(-1);</script>";
}
else
{
$msg = mysql_error();
echo "<script>alert('$msg'); history.go(-1);</script>";
//echo "<script>alert('系统繁忙,请稍候!'); history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('密码不一致!'); history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('提交未成功!'); history.go(-1);</script>";
}
?>
这是全部的代码 其实别的都能跳转能用就那段有点问题
把 $res_insert = mysql_query($sql_insert);
改为 $res_insert = mysql_query($sql_insert) or die(mysql_error());
Unknown column 'turename' in 'field list' 额求解
好吧 我的错 字打错了
哎 实在是太马虎了 不过学到了怎么找sql问题 谢谢大神
turename 列不存在