有人可以帮忙,mysqli更新不更新

时间:2014-01-29 17:12:23

标签: php mysql mysqli

if (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();}

      else{
            $query = "SELECT GroomingID FROM grooming
                WHERE Email = '" . $dbEntries['Email'] .
                "' AND PhoneNumber = '" . $dbEntries['PhoneNumber'] . "'";
            $result = $con->query($query);
    if ($result->num_rows)
    {
        $row = $result->fetch_assoc();
        $ID = $row['GroomingID'];
        echo $Cancel;
        echo $ID;
        mysqli_query($con,"UPDATE Grooming SET Cancelled=$Cancel 
                            WHERE GroomingID = $ID");

echo '<div align="center">Registration Successful</div>';

echo 'groomingid is ' . $ID;

1 个答案:

答案 0 :(得分:1)

错误可能是您使用$ ID作为字符串;这样做:

  

$ID=intval($row['GroomingID']);

更好的方法是使用bind params进行查询:http://www.php.net/manual/en/mysqli-stmt.bind-param.php