Advertisement
Guest User

Untitled

a guest
May 23rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. <?php
  2.  
  3. $hostname='localhost';
  4. $user='';
  5. $password='';
  6. if (isset($_GET['gameid'])) {
  7. $gameid = $_GET['gameid'];
  8. }
  9. if (isset($_GET['id'])) {
  10. $id = $_GET['id'];
  11. echo $id;
  12. }
  13. if (isset($_GET['questionid'])) {
  14. $questionid = $_GET['questionid'];
  15. }
  16. $new = 0;
  17.  
  18. if (isset($_GET['gameid'])) {
  19.  
  20. try {
  21. $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
  22.  
  23. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  24. $sql = "SELECT *
  25. FROM questions_de WHERE id = '$questionid'
  26. LIMIT 1";
  27. if ($res = $dbh->query($sql)) {// need to add this line in your code
  28. // then after fetchColumn
  29. $question = $res->fetchAll();
  30.  
  31. }
  32.  
  33. if($question > 0) {
  34. //do something
  35. }
  36. else {
  37.  
  38. echo "Sorry something happen wrong with our servers.";
  39. }
  40. }
  41. catch(PDOException $e) {
  42.  
  43.  
  44. }
  45. if ($question[0]["answerm²"] == 0 && $question[0]["answerm³"] == 0) {
  46.  
  47. $answer = "answer_m";
  48. }
  49.  
  50. else {
  51.  
  52. $answer = "answerm³";
  53. }
  54. }
  55. if (isset($_GET['id'])) {
  56. try {
  57. $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
  58.  
  59. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  60. $sql = "SELECT username
  61. FROM user WHERE id = '$id'
  62. LIMIT 1"; //
  63. if ($res = $dbh->query($sql)) {// need to add this line in your code
  64. // then after fetchColumn
  65. $user2name = $res->fetchAll();
  66.  
  67. }
  68.  
  69. if($user2name > 0) {
  70. //do something
  71. }
  72. else {
  73.  
  74. echo "Sorry something happen wrong with our servers.";
  75. }
  76. }
  77. catch(PDOException $e) {
  78.  
  79.  
  80. }
  81.  
  82. try {
  83. $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
  84.  
  85. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  86. $sql = "SELECT *
  87. FROM questions_de
  88. LIMIT 1"; //
  89. if ($res = $dbh->query($sql)) {// need to add this line in your code
  90. // then after fetchColumn
  91. $question = $res->fetchAll();
  92.  
  93. }
  94.  
  95. if($question > 0) {
  96. //do something
  97. }
  98. else {
  99.  
  100. echo "Sorry something happen wrong with our servers.";
  101. }
  102. }
  103.  
  104. catch(PDOException $e) {
  105.  
  106.  
  107. }
  108.  
  109.  
  110. if ($question[0]["answerm²"] == 0 && $question[0]["answerm³"] == 0) {
  111. try {
  112. $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
  113.  
  114. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  115. $sql = "INSERT INTO game_create (user1, user2, user1name, user2name, question, questionid, answer)
  116. VALUES ('".$_COOKIE["userid"]."', '".$id."', '".$_COOKIE["username"]."', '".$user2name[0]["username"]."', '".$question[0]['question']."', '".$question[0]['id']."', '".$question[0]['answer_m']."')";
  117.  
  118. if ($dbh->query($sql)) {
  119. //echo "New Record Inserted Successfully";
  120. }
  121. else{
  122. // echo "Data not successfully Inserted.";
  123. }
  124. $new = $dbh->lastInsertId();
  125. $dbh = null;
  126. }
  127. catch(PDOException $e)
  128. {
  129. echo $e->getMessage();
  130. }
  131.  
  132. if ($new > 0) {
  133.  
  134. } else {
  135. echo 'Sorry something went wrong.';
  136. }
  137. $answer = "answer_m";
  138. }
  139. else {
  140. try {
  141. $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
  142.  
  143. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  144. $sql = "INSERT INTO game_create (user1, user2, user1name, user2name, question, questionid, answer)
  145. VALUES ('".$_COOKIE["userid"]."', '".$id."', '".$_COOKIE["username"]."', '".$user2name[0]["username"]."', '".$question[0]['question']."', '".$question[0]['id']."', '".$question[0]['answer_m³']."')";
  146.  
  147. if ($dbh->query($sql)) {
  148. //echo "New Record Inserted Successfully";
  149. }
  150. else{
  151. // echo "Data not successfully Inserted.";
  152. }
  153. $new = $dbh->lastInsertId();
  154. $dbh = null;
  155. }
  156. catch(PDOException $e)
  157. {
  158. echo $e->getMessage();
  159. }
  160.  
  161. if ($new > 0) {
  162.  
  163. } else {
  164. echo 'Sorry something went wrong.';
  165. }
  166. $answer = "answerm³";
  167.  
  168. }
  169. }
  170. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement