Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. try{
  2.  
  3. $user = 'root';
  4. $pass = null;
  5. $pdo = new PDO('mysql:host=localhost; dbname=divebay', $user, $pass);
  6.  
  7. $name = $_POST['name'];
  8. $desc = $_POST['description'];
  9. $cond = $_POST['condGroup'];
  10. $sprice = $_POST['sprice'];
  11. $iprice = $_POST['iprice'];
  12. $incprice = $_POST['incprice'];
  13. $duration = $_POST['duration'];
  14. $img = $_POST['img'];
  15.  
  16.  
  17. $owner = $_SESSION['username'];
  18.  
  19. $valid = "set";
  20. $stmt2 = $pdo->prepare("SELECT * FROM auction WHERE ID = :id");
  21. $stmt2->bindParam(":id", $random, PDO::PARAM_INT);
  22. while(isset($valid)){
  23. $random = rand(100000,999999);
  24. $stmt2->execute();
  25.  
  26. if(!$stmt2->fetch(PDO::FETCH_ASSOC)){
  27. unset($valid);
  28. }
  29. }
  30.  
  31. $timestamp = time() + ($duration * 24 * 60 * 60);
  32.  
  33. $stmt = $pdo->prepare("INSERT INTO auction(ID, name, owner, holder, sprice, iprice, incprice, etime, img, condition, description)
  34. VALUES (:id, :name, :owner, :holder, :sprice, :iprice, :incprice:, :etime, :img, :condition, :description");
  35. $stmt->bindParam(':id', $random, PDO::PARAM_INT);
  36. $stmt->bindParam(':name', $name, PDO::PARAM_STR);
  37. $stmt->bindParam(':owner', $owner, PDO::PARAM_STR);
  38. $stmt->bindParam(':holder', $owner, PDO::PARAM_STR);
  39. $stmt->bindParam(':iprice', $iprice, PDO::PARAM_STR);
  40. $stmt->bindParam(':sprice', $sprice, PDO::PARAM_STR);
  41. $stmt->bindParam(':incprice', $incprice, PDO::PARAM_STR);
  42. $stmt->bindParam(':etime', $timestamp, PDO::PARAM_INT);
  43. $stmt->bindParam(':img', $img, PDO::PARAM_STR);
  44. $stmt->bindParam(':condition', $condition, PDO::PARAM_STR);
  45. $stmt->bindParam(':description', $description, PDO::PARAM_STR);
  46. if($stmt->execute()){
  47. $worked ="yes";
  48. }
  49.  
  50. }catch(PDOException $e){
  51. echo $e->getMessage();
  52. }
  53.  
  54. $pdo = new PDO('mysql:host=localhost; dbname=divebay;charset=utf8', $user, $pass);
  55. $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  56. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  57.  
  58. $stmt = $pdo->prepare("INSERT INTO auction(ID, name, owner, holder, sprice, iprice, incprice, etime, img, condition, description)
  59. VALUES (:id, :name, :owner, :holder, :sprice, :iprice, :incprice:, :etime, :img, :condition, :description)");
  60. ^
  61.  
  62. $stmt = $pdo->prepare("INSERT INTO auction(ID, name, owner, holder, sprice, iprice, incprice, etime, img, condition, description)
  63. VALUES (:id, :name, :owner, :holder, :sprice, :iprice, :incprice:, :etime, :img, :condition, :description");
  64.  
  65. $stmt = $pdo->prepare("INSERT INTO auction(ID, name, owner, holder, sprice, iprice, incprice, etime, img, condition, description)
  66. VALUES (:id, :name, :owner, :holder, :sprice, :iprice, :incprice:, :etime, :img, :condition, :description)");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement