Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code


<pre><?php
if (isset($_POST['ingresarsim'])) {
	$ingresarSim = trim($_POST['ingresarsim']);



	}
 
$conexv = mysqli_connect("localhost","root","") or die("problemas al conectar");

mysqli_select_db($conexv,"ventas") or die("problemas base de datos");

$reg = mysqli_prepare($conexv, "SELECT COUNT(*) FROM ventas WHERE id = ?");
mysqli_stmt_bind_param($reg, "i", $ingresarSim);
mysqli_stmt_execute($reg);

$conteoFilas = mysqli_stmt_get_result($reg);

if (!$reg) {
    print_r(mysqli_error($conexv));
} else {
    if ($conteoFilas->field_count > 0) {
        $eliminado = mysqli_query($conexv, "DELETE FROM sim WHERE id = ?")or die ("Problemas en consulta:". mysqli_error($conexv));
;
        mysqli_stmt_bind_param($eliminado, "i", $ingresarSim);
        mysqli_stmt_execute($eliminado);
        echo "Datos Eliminados";
    } else {
        echo "Datos no han sido Eliminados";
    }
}
?>





What I have tried:

I have tried a lot of advice online but couldnt resolve this error.
Posted
Updated 20-Oct-20 2:19am
Comments
Richard MacCutchan 20-Oct-20 3:37am    
Which statement, and are you certain that $ingresarSim is an integer value?
Nathanael De Leon 20-Oct-20 4:00am    
$ _POST ['ingresarsim'], is everything that enters a text box called ingresarsim and $ingresarSim is its variable, in integer, right?
Richard MacCutchan 20-Oct-20 4:10am    
How would I know? Use your debugger to check exactly what object type is being posted. If it is not an integer then your code needs to convert it. Either in your Web page, or before using it in your database statements.

1 solution

It looks like you're trying to use mysqli_stmt_bind_param on the result of a mysqli_query which you can't do, you need to use mysqli_prepare as described in this Stackoverflow post[^]

You need to change the line starting $eliminado = mysqli_query
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900