Advertisement
Guest User

Untitled

a guest
Mar 30th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. $con = mysqli_connect("localhost","root","","realestatecompany");
  3. if(!$con) {
  4. echo "Error";
  5. }
  6. //$con->close();
  7. ?>
  8.  
  9. <?php
  10. require_once 'dbconnector.php';
  11. class userAccount {
  12. public $userName;
  13. public $userPass;
  14. public $userType;
  15. public function __construct ($UserName, $Password, $Type, $con) {
  16. $this->userName = $UserName;
  17. $this->userPass = $Password;
  18. $this->userType = $Type;
  19. }
  20. public function writeInDB() {
  21. $sql = "INSERT INTO login (userName,userPass,userType) values (".$this->userName.",".$this->userPass.",".$this->userType.")";
  22. if ($con->query($sql) === TRUE) {
  23. echo "Record Added successfully";
  24. } else {
  25. echo "Error Adding record: " . $conn->error;
  26. }
  27. }
  28. public function editInDB($userNewAccount, $userID) {
  29. $a = $userNewAccount->userName;
  30. $b = $userNewAccount->userPass;
  31. $c = $userNewAccount->userType;
  32. $sql = "UPDATE login SET userName =".$a.", userPass ='".$b."', userType =".$c." WHERE userID =".$userID;
  33. echo $sql;
  34. }
  35. }
  36. $x = new userAccount("Heba", "Taba3", 1, $con);
  37. $x->writeInDB();
  38.  
  39. Notice: Undefined variable: con in D:xampphtdocsswprojectobjects.php on line 14
  40.  
  41. Fatal error: Uncaught Error: Call to a member function query() on unknown in D:xampphtdocsswprojectobjects.php:14 Stack trace: #0 D:xampphtdocsswprojectobjects.php(29): userAccount->writeInDB() #1 {main} thrown in D:xampphtdocsswprojectobjects.php on line 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement