Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname='localhost';
- $user='';
- $password='';
- if (isset($_GET['gameid'])) {
- $gameid = $_GET['gameid'];
- }
- if (isset($_GET['id'])) {
- $id = $_GET['id'];
- echo $id;
- }
- if (isset($_GET['questionid'])) {
- $questionid = $_GET['questionid'];
- }
- $new = 0;
- if (isset($_GET['gameid'])) {
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "SELECT *
- FROM questions_de WHERE id = '$questionid'
- LIMIT 1";
- if ($res = $dbh->query($sql)) {// need to add this line in your code
- // then after fetchColumn
- $question = $res->fetchAll();
- }
- if($question > 0) {
- //do something
- }
- else {
- echo "Sorry something happen wrong with our servers.";
- }
- }
- catch(PDOException $e) {
- }
- if ($question[0]["answerm²"] == 0 && $question[0]["answerm³"] == 0) {
- $answer = "answer_m";
- }
- else {
- $answer = "answerm³";
- }
- }
- if (isset($_GET['id'])) {
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "SELECT username
- FROM user WHERE id = '$id'
- LIMIT 1"; //
- if ($res = $dbh->query($sql)) {// need to add this line in your code
- // then after fetchColumn
- $user2name = $res->fetchAll();
- }
- if($user2name > 0) {
- //do something
- }
- else {
- echo "Sorry something happen wrong with our servers.";
- }
- }
- catch(PDOException $e) {
- }
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "SELECT *
- FROM questions_de
- LIMIT 1"; //
- if ($res = $dbh->query($sql)) {// need to add this line in your code
- // then after fetchColumn
- $question = $res->fetchAll();
- }
- if($question > 0) {
- //do something
- }
- else {
- echo "Sorry something happen wrong with our servers.";
- }
- }
- catch(PDOException $e) {
- }
- if ($question[0]["answerm²"] == 0 && $question[0]["answerm³"] == 0) {
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "INSERT INTO game_create (user1, user2, user1name, user2name, question, questionid, answer)
- VALUES ('".$_COOKIE["userid"]."', '".$id."', '".$_COOKIE["username"]."', '".$user2name[0]["username"]."', '".$question[0]['question']."', '".$question[0]['id']."', '".$question[0]['answer_m']."')";
- if ($dbh->query($sql)) {
- //echo "New Record Inserted Successfully";
- }
- else{
- // echo "Data not successfully Inserted.";
- }
- $new = $dbh->lastInsertId();
- $dbh = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- if ($new > 0) {
- } else {
- echo 'Sorry something went wrong.';
- }
- $answer = "answer_m";
- }
- else {
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=maxiqsoft_com_db_socame",$user,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "INSERT INTO game_create (user1, user2, user1name, user2name, question, questionid, answer)
- VALUES ('".$_COOKIE["userid"]."', '".$id."', '".$_COOKIE["username"]."', '".$user2name[0]["username"]."', '".$question[0]['question']."', '".$question[0]['id']."', '".$question[0]['answer_m³']."')";
- if ($dbh->query($sql)) {
- //echo "New Record Inserted Successfully";
- }
- else{
- // echo "Data not successfully Inserted.";
- }
- $new = $dbh->lastInsertId();
- $dbh = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- if ($new > 0) {
- } else {
- echo 'Sorry something went wrong.';
- }
- $answer = "answerm³";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement