sql - PHP Warning: mysqli_stmt_bind_result() -
i new programing not php @ all. doing siple project of mine improve myself. did onec want make queries work prepared statements new me...
$create_stmt = mysqli_prepare($connection, "insert `users`(`user_name`, `password`) values (?,?)"); if(!$create_stmt){ echo 'error'; exit; } mysqli_stmt_bind_param($create_stmt, 'ss',$username,$password); mysqli_stmt_execute($create_stmt); mysqli_stmt_bind_result($create_stmt, $new_uname, $new_unamepass); mysqli_stmt_fetch($create_stmt); so here deal. having kind of error:
warning: mysqli_stmt_bind_result(): number of bind variables doesn't match number of fields in prepared statement.
since want add 2 values 'users' table declaring 2 new variables $new_uname, $new_unamepass, somehow not correct...
also mysqli_stmt_fetch($create_stmt); not true should if ok (obviously not ok..) please if can me or give me advice, great!
try this:
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world'); /* check connection */ if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } $stmt = $mysqli->prepare("insert `users`(`user_name`, `password`) values (?,?)"); $stmt->bind_param('ss', $user, $pass); $user='username'; $pass = 'password1234'; /* execute prepared statement */ $stmt->execute(); printf("%d row inserted.\n", $stmt->affected_rows); /* close statement , connection */ $stmt->close();
Comments
Post a Comment