I cant insert in mysql from php -
whats solution problem number of elements in type definition string doesn't match number of bind variables
session_start(); $regvalue1 = $_get['un']; $regvalue2 = $_get['pass']; $regvalue3 = $_get['fn'] ; $regvalue4 = $_get['ln']; $regvalue5 = $_get['age'] ; $regvalue6 = $_get['sex']; $regvalue7 = $_get['em'] ; echo "hello: ".$regvalue3."."; $servername = "localhost"; username = "root"; $password = "b4sonic"; $dbname = "blog"; $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("insert register(un,pass,fn,ln,age,sex,email) values (?,?,?,?,?,?,?)"); bind_param("sss",$regvalue1, $regvalue2,$regvalue3,$regvalue4,$regvalue5,$regvalue6,$regvalue7); $stmt->execute(); echo "new records created successfully"; $stmt->close(); $conn->close(); ?>
i have code in php , trying insert data mysql face problem number of elements in type definition string doesn't match number of bind variables
your type string in statement doesn't have enough type specifiers in it.
bind_param("sss",$regvalue1,$regvalue2,$regvalue3,$regvalue4,$regvalue5,$regvalue6,$regvalue7);
says have type "sss" corresponds 3 of 7 variables specified. need add types rest.
from documentation:
var1
the number of variables , length of string types must match parameters in statement.
Comments
Post a Comment