sql >> Base de Datos >  >> RDS >> Mysql

Datos no almacenados usando declaraciones preparadas

Le sugiero que envuelva todo el bind_param y lo ejecute con una condición if, ya que la declaración no se preparará incluso si hay un problema menor. En este caso, supongo que podría ser que los tipos de cada variable/campo sean incorrectos en algún momento, probablemente la image / b parte.

Puede repetir el tipo de cada uno usando gettype que podría ayudar a localizarlo:

echo gettype($first), gettype($email), gettype($phone),
     gettype($school), gettype($dob), gettype($father), 
     gettype($feereceived), gettype($due), gettype($image);


$db = new mysqli("localhost", "root","","learndb");

if ($db->connect_error) {
    die("Connection failed this is the error: " . $db->connect_error);
}

$stmt = $db->prepare("INSERT INTO studentrecords (`Name`, `email`, `Phone`, `school`,`dob`,`father`,`feereceived`,`due`,`image`) VALUES (?,?,?,?,?,?,?,?,?)");

if($stmt) {
    $stmt->bind_param("ssisssiib",$first,$email,$phone,$school,$dob,$father,$feereceived,$due,$image);
    $stmt->execute();
} else {
    echo 'Failed to prepare the sql statement';
}