我在我的网站上创建了两个级别的注册,在第一级注册中我可以将我的价值存储在数据库中,但在第二级我不能存储在同一个表中。
在第一个寄存器中我使用了一个插入查询,在同一个表的第二级寄存器中,我使用了更新查询。
如果我在可以存储的条件中给出了直接行值,如果我给出user_id
我不应该接受。
首先注册:
public function register($uname,$umail,$upass,$mobile,$gender)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO users(user_name,user_email,user_pass,mobile,gender)
VALUES(:uname, :umail, :upass, :mobile, :gender )");
$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->bindparam(":mobile", $mobile);
$stmt->bindparam(":gender", $gender);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
第二次注册:
public function register1($marital_status,$applicant_photo,$date_of_birth,$home_name,$birth_time)
{
try
{
$stmt = $this->conn->prepare("UPDATE users SET marital_status= :marital_status, applicant_photo=:applicant_photo, date_of_birth=:date_of_birth, home_name=:home_name, birth_time=:birth_time WHERE user_id =':user_id'");
$stmt->bindparam(":marital_status", $marital_status);
$stmt->bindparam(":applicant_photo", $applicant_photo);
$stmt->bindparam(":date_of_birth", $date_of_birth);
$stmt->bindparam(":home_name", $home_name);
$stmt->bindparam(":birth_time", $birth_time);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
提前致谢
答案 0 :(得分:1)
您需要将$user_id
作为参数传递给function
和bind
,就像这样
第一名:bind
user_id
$stmt->bindparam(":user_id", $user_id);
user_id =':user_id'
第二名并删除单引号
user_id =:user_id
更改为
import itertools
import numpy as np
x_dim=np.arange(0.0, 1.0, 0.01)
y_dim=np.arange(0.0, 1.0, 0.01)
z_dim=np.arange(0.0, 1.0, 0.01)
i=0
values=[]
L=[]
I=[]
maxI=defaultdict(dict)
for w, x, y in itertools.product(x_dim, y_dim, z_dim):
s=w+x+y
if s<1:
z=1-s
values.append([w,x,y,z])
for params in values:
new_pList=probList*params
L.append(np.prod(np.sum(new_pList, axis=1)))
I.append([w,x,y,z])
k=0
for item in L:
maxI[item]=I[k]
k+=1
maxI=sorted(maxI.items(), key=lambda x: x[0], reverse=True)
print(maxI[0:5])
答案 1 :(得分:1)
代码中的3个错误
user_id =':user_id'
更改为user_id =:user_id
,即删除单引号bindparam
到user_id,即$stmt->bindparam(":user_id", $user_id);
尝试更改此代码
public function register($uname,$umail,$upass,$mobile,$gender,$user_id)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO users(user_name,user_email,user_pass,mobile,gender,user_id)
VALUES(:uname, :umail, :upass, :mobile, :gender, :user_id )");
$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->bindparam(":mobile", $mobile);
$stmt->bindparam(":gender", $gender);
$stmt->bindparam(":user_id", $user_id);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
第二次注册
public function register1($marital_status,$applicant_photo,$date_of_birth,$home_name,$birth_time)
{
try
{
$stmt = $this->conn->prepare("UPDATE users SET marital_status= :marital_status, applicant_photo=:applicant_photo, date_of_birth=:date_of_birth, home_name=:home_name, birth_time=:birth_time WHERE user_id =:user_id");
$stmt->bindparam(":marital_status", $marital_status);
$stmt->bindparam(":applicant_photo", $applicant_photo);
$stmt->bindparam(":date_of_birth", $date_of_birth);
$stmt->bindparam(":home_name", $home_name);
$stmt->bindparam(":birth_time", $birth_time);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
答案 2 :(得分:0)
使用此
{"HT" : ["#SoccerTips" , "#FootballTips", " ", "#FixedMatch", "#CT2017Final"]}
我觉得它对你有用。