Guest User

Untitled

a guest
Sep 2nd, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. what is wrong with this code
  2. class MyClass {
  3.  
  4. private $db;
  5.  
  6. // Constructor
  7. function __construct() {
  8. $this->db = new mysqli('localhost', 'root', 'root', 'Test_db');
  9. $this->db->autocommit(FALSE);
  10. }
  11.  
  12. // Destructor
  13. function __destruct() {
  14. $this->db->close();
  15. }
  16.  
  17. // Main method
  18. function MyFun() {
  19.  
  20. // Check for required parameters
  21. if (isset($_POST["name"]) && isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["email"])) {
  22. echo "Before n";
  23. $name = $_POST["name"];
  24. $username = $_POST["username"];
  25. $password = $_POST["password"];
  26. $email = $_POST["email"];
  27. $activation = 0;
  28. echo "After n";
  29. // tracking
  30. $stmt = $this->db->prepare("INSERT INTO users (name, username, password, email,activation) VALUES (?, ?, ?, ?, ?)");
  31. $stmt->bind_param("is", $name, $username, $password, $email, $activation); //Line 95
  32. $stmt->execute();
  33. $stmt->close();
  34.  
  35. }
  36.  
  37. [15-Apr-2011 15:09:10] PHP Warning: mysqli_stmt::bind_param() [<a href='function.mysqli-stmt-bind-param'>function.mysqli-stmt-bind-param</a>]: Number of elements in type definition string doesn't match number of bind variables in /Applications/MAMP/htdocs/Test/reg.php on line 95
  38.  
  39. $stmt->bind_param("is", $name, $username, $password, $email, $activation);
  40.  
  41. $stmt->bind_param("sssss", $name, $username, $password, $email, $activation);
  42.  
  43. $stmt->bind_param("is", $name, $username, $password, $email, $activation);
  44.  
  45. $stmt = $this->db->prepare("INSERT INTO users (name, username, password, email,activation) VALUES (?, ?, ?, ?, ?)");
  46. $stmt->bind_param($name, $username, $password, $email, $activation);
  47.  
  48. $stmt = $this->db->prepare("INSERT INTO users (**is**, name, username, password, email,activation) VALUES (?, ?, ?, ?, ?)");
  49. $stmt->bind_param("**is**", $name, $username, $password, $email, $activation);
Add Comment
Please, Sign In to add comment