このコードでは、準備済みの文クエリを使用していますが、行数が必要ですが、次のコードではゼロ行が返されます。私のコードで何が間違っているか教えてください。次のコードでは、行数を常にゼロに戻します。
$servername = "localhost";
$username = "root";
$password = "";
$dbname="lamp";
$conn = new mysqli($servername,$username,$password,$dbname);
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$contactno=mysqli_real_escape_string($conn,$_POST['contactno']);
$description=mysqli_real_escape_string($conn,$_POST['description']);
$email=mysqli_real_escape_string($conn,$_POST['contactemail']);
$subject=mysqli_real_escape_string($conn,$_POST['subject']);
$creationdate=mysqli_real_escape_string($conn,$_POST['creationdate']);
if(isset($_POST['status1']))
{
$status =$_POST['status1'];
}
if(isset($_POST['noteid']))
{
$id = mysqli_real_escape_string($conn,$_POST['noteid']);
}
$stmt=$conn->prepare("update notifications set subject=?,description=?
,status=?, creationdate=?,contactno=?,contactemail=? where id=? "); $stmt->bind_param("ssisisi",$subject,$description,$status,$creationdate,$contactno,$email,$id);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows >0)
{
echo "sucess";
header("Location: updategovermentnotification.php");
}
次のように試してみてください: 'update'はnum_rows' –
があれば、' '使用する必要が戻る文句を言わないのでhttp://www.w3schools.com/php/php_mysql_update.asp (mysqli_affected_rows($ CONN)> 0){' 'if($ stmt-> num_rows> 0){'の代わりに、更新は成功したかどうかに基づいて真または偽を返すので –