这个查询有什么问题

时间:2014-04-10 08:08:25

标签: php mysql database

$query = "INSERT INTO patients ( username, idn, email, mobilenumber, healthcenter, height, weight, city, state ) 
    VALUES ( :name, :id, :mail, :mn, :hc, :heightv, :weightv, :cityv, :statev ) ";

//Again, we need to update our tokens with the actual data:

$query_params = array(
    ':name' => $_POST['username'],
    ':id' => $_POST['idn'],
    ':mail' => $_POST['email'],
    ':mn' => $_POST['mobilenumber'],
    ':hc' => $_POST['healthcenter'],
    ':hightv' => $_POST['height'],
    ':weightv' => $_POST['weight'],
    ':cityv' => $_POST['city'],
    ':statev' => $_POST['state']
);

//time to run our query, and create the user

try {
    $stmt   = $db->prepare($query);
    $result = $stmt->execute($query_params);
}

1 个答案:

答案 0 :(得分:2)

在您的query_params中,您拼错了heightv

你应该使用

':heightv' => $_POST['height'],

而不是

':hightv' => $_POST['height'],