Israel

Israel

  • 994
  • 1.3k
  • 154.5k

Doesnt save into my DB

Jan 28 2021 4:54 PM
Hi,
 
Ouuuuuuf, I do pass many hours to resolv this. NOTHING!!! 
I do connect to database witount the problem.
But this code doesnt save into my database. 
  1. $SQL->bind_param($SQL,'sssssd'$firstName$lastname$gender$email$passw$num);  
Its gives this error:
Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\dashboard\RegistrationForm_save\connect.php:51 Stack trace: #0 {main} thrown in C:\xampp\htdocs\dashboard\RegistrationForm_save\connect.php on line 34
 
Please  this my codes:
 
index.html
  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>    
  4.     <title>Registration Page</title>    
  5.     <link rel="stylesheet" type="text/css" href="css/bootstrap.css">    
  6. </head>    
  7. <body>    
  8.     <div class="container">    
  9.         <div class="row col-md-6 col-md-offset-3">    
  10.             <div class="panel panel-primary">    
  11.                 <div class="panel-heading text-center">    
  12.                     <h1>Registration Form</h1>    
  13.                 </div>    
  14.                 <div class="panel-body">    
  15.                         <form action="connect.php" method="post">    
  16.                                 <div class="form-group">    
  17.                                     <label for="firstName">First Name</label>    
  18.                                     <input type="text" class="form-control" id="firstName" />    
  19.                                 </div>    
  20.                                 <div class="form-group">    
  21.                                     <label for="lastName">Last Name</label>    
  22.                                     <input type="text" class="form-control" id="lastName" />    
  23.                                 </div>    
  24.                                 <div class="form-group">    
  25.                                     <label for="email">Gender</label>    
  26.                                     <div>    
  27.                                         <label for="male" class="radio-inline"><input type="radio" name="gender" value="m" id="male">Male</label>    
  28.                                         <label for="female" class="radio-inline"><input type="radio" name="gender" value="m" id="male">Female</label>    
  29.                                         <label for="others" class="radio-inline"><input type="radio" name="gender" value="o" id="male">Others</label>    
  30.                                     </div>    
  31.                                 </div>    
  32.                                 <div class="form-group">    
  33.                                     <label for="email">Email</label>    
  34.                                     <input type="text" class="form-control" id="email" name="email" />    
  35.                                 </div>    
  36.                                 <div class="form-group">    
  37.                                     <label for="passw">password</label>    
  38.                                     <input type="passw" class="form-control" id="passw" name="passw" />    
  39.                                 </div>    
  40.                                 <div class="form-group">    
  41.                                     <label for="num">Phone Number</label>    
  42.                                     <input type="num" class="form-control" id="num" name="num" />    
  43.                                 </div>    
  44.                                 <input type="submit" class="btn btn-primary">    
  45.                                 </form>    
  46.                             </div>    
  47.                             <div class="panel-footer text-right">    
  48.                                 <small>© Israel Mfwamba</small>    
  49.                             </div>    
  50.                         </div>  
index.php
  1. $servername = "localhost:3307";  
  2. $database = "registrationform1";  
  3. $db_found = new mysqli($servername$database );  
  4. $SQL = $db_found->prepare("INSERT INTO registration (firstName, lastname, gender, email, passw, num) VALUES (?, ?, ?, ?, ?, ?)");  
  5. //$SQL->bind_param('ssssss', $firstName, $lastname, $gender, $email, $passw, $num);  
  6. $SQL->bind_param($SQL,'sssssd'$firstName$lastname$gender$email$passw$num);  
  7. $SQL->execute();  
  8. $stmt = $conn->prepare($SELECT);  
  9. $stmt->bind_param("s"$firstName$lastname$gender$email$passw$num);  
  10. $stmt->execute();  
  11. $stmt->bind_result($firstName$lastname$gender$email$passw$num);  
  12. $stmt->store_result();  
  13. $rnum = $stmt->num_rows;  
  14. if ($rnum==0)  
  15. {  
  16. $stmt->close();  
  17. $stmt = $conn->prepare($INSERT);  
  18. $stmt->bind_param("ssssss"$firstName$lastname$gender$email$passw$num);  
  19. $stmt->execute();  
  20. echo "New record inserted sucessfully";  
  21. }  
  22. ?> 

Answers (3)