Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting();
- session_start();
- $MYSQL_HOST = 'localhost';
- $MYSQL_DB = 'eatt';
- $MYSQL_PASSWORD = '';
- $MYSQL_USER = 'root';
- try
- {
- $connection = new PDO("mysql:host={$MYSQL_HOST};dbname={$MYSQL_DB}",$MYSQL_USER,$MYSQL_PASSWORD);
- $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- class TrashCodeXD
- {
- protected $db;
- public function __construct($connection)
- {
- $this->db = $connection;
- }
- public function WhatsThis()
- {
- $SQL = $this->db->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM posts");
- $SQL->execute();
- $result = $this->db->prepare("SELECT FOUND_ROWS()");
- $result->execute();
- $rows = $result->fetchColumn();
- if($SQL->rowCount() > 20)
- {
- $rows = $SQL->fetch(PDO::FETCH_ASSOC);
- $_SESSION['post'] = $rows;
- $r1 = rand(1, $rows);
- $r2 = rand(1, $rows);
- $r3= rand(1, $rows);
- $r4 = rand(1, $rows);
- $r5 = rand(1, $rows);
- $r6 = rand(1, $rows);
- $r7 = rand(1, $rows);
- $r8 = rand(1, $rows);
- $r9 = rand(1, $rows);
- $r10 = rand(1, $rows);
- $r11 = rand(1, $rows);
- $myarray = array($r1, $r2, $r3, $r4, $r5, $r6, $r7, $r8, $r9, $r10, $r11);
- while($array_counter < 10)
- {
- $theid = $myarray[$array_counter];
- $SQL = $this->db->prepare("SELECT * FROM posts WHERE id = :id");
- $SQL->bindParam(":id",$theid);
- $result = $SQL->execute();
- $pst_row = $SQL->fetch(PDO::FETCH_ASSOC);
- if($result)
- {
- $_SESSION['user_data']['post'] = $pst_row;
- $string .= "<div id='post'>".$_SESSION['user_data']['post']['person']."<div>".$_SESSION['user_data']['post']['content']."</div><div id='base'><span class='mark'>Mark</span><span class='comment'>Comment</span><span class='views'>Views</span>".$_SESSION['user_data']['post']['date']."</div></div>";
- var_dump($string);
- echo 'checking....';
- }else{
- echo "<br /> An error has occured";
- }
- $array_counter++;
- }
- echo $string;
- }else{
- $r1 = rand(1, $rows);
- $SQL = $this->db->prepare("SELECT * FROM posts WHERE id = :id");
- $SQL->bindParam(":id",$r1);
- $result = $SQL->execute();
- $pst_row = $SQL->fetch(PDO::FETCH_ASSOC);
- if($result)
- {
- $_SESSION['user_data']['post'] = $pst_row;
- $string = "<div id='post'>".$_SESSION['user_data']['post']['person']."<div>".$_SESSION['user_data']['post']['content']."</div><div id='base'><span class='mark'>Mark</span><span class='comment'>Comment</span><span class='views'>Views</span>".$_SESSION['user_data']['post']['date']."</div></div>";
- echo '<pre align="left" style="text-indent:10px; color:#fff;"></pre>';
- echo $string;
- }else{
- echo "<br /> An error has occured";
- }
- }
- }
- }
- $object = new TrashCodeXD($connection);
- $object->WhatsThis()
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement