Good afternoon community stack , I'm doing some queries prepared with mysqli the query is successful but if agrgo mysqli_num_rows
throws me error.
example this is the code that throws me wrong ...
$me=$_SESSION["id"];
$name=$_SESSION["usuario"];
$id =$_GET["id"];
$query3 = "SELECT user_id,post_id FROM post_views WHERE user_id = ? AND post_id=?";
$result3=mysqli_prepare($conexion,$query3);
$ok3=mysqli_stmt_bind_param($result3, "ii",$me,$id);
$ok3=mysqli_stmt_execute($result3);
if ($ok3==false) {
echo "error".mysqli_error($conexion);
}else{
if (mysqli_num_rows($result3)>0) {// si el usuario ya esta no me lo insertes
echo "not again";
}else{ //si el usuario no estas insertalo
$sql="INSERT INTO post_views (user_id,post_id,user_name)VALUES(?,?,?)";
$result2=mysqli_prepare($conexion,$sql);
$ok2=mysqli_stmt_bind_param($result2, "iis",$me, $id,$name);
$ok2=mysqli_stmt_execute($result2);
}
mysqli_stmt_close($result3);
}
This is the error that the console shows me:
"\ r \ n
\ n Warning : mysqli_num_rows () expects parameter 1 to be mysqli, object given in C: \ xampp \ htdocs \ get_info_img_profile.php on line 35
\ n
\ n Warning : mysqli_stmt_bind_param () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ get_info_img_profile.php on line 43
\ n
\ n Warning : mysqli_stmt_execute () expects parameter 1 to be mysqli_stmt, boolean given in C: \ xampp \ htdocs \ get_info_img_profile.php on line 44 \ n {\ "count \": \ "10 \", \ "num_coments \": 0, \ "num_eva \": 1, \ "num_sync \": 3} "
now if I remove the condition of mysqli_num_rows
proceed and execute the example code:
$me=$_SESSION["id"];
$name=$_SESSION["usuario"];
$id =mysqli_real_escape_string($conexion, $_GET["id"]);
$count =$conexion, $_GET["count"];
$query3 = "SELECT user_id,post_id FROM post_views WHERE user_id = ? AND post_id=?";
$result3=mysqli_prepare($conexion,$query3);
$ok3=mysqli_stmt_bind_param($result3, "ii",$me,$id);
$ok3=mysqli_stmt_execute($result3);
if ($ok3==false) {
echo "error".mysqli_error($conexion);
}else{
$sql="INSERT INTO post_views (user_id,post_id,user_name)VALUES(?,?,?)";
$result2=mysqli_prepare($conexion,$sql);
$ok2=mysqli_stmt_bind_param($result2, "iis",$me, $id,$name);
$ok2=mysqli_stmt_execute($result2);
mysqli_stmt_close($result3);
}
I hope you can help me with this error thanks!