Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. <?
  2.  
  3. $con = mysql_connect("localhost","inmoti6_myuser","mypassword");
  4.  
  5. if (!$con)
  6. {
  7.   die('Could not connect: ' . mysql_error());
  8. }
  9.  
  10. mysql_select_db("inmoti6_mysite", $con);
  11.  
  12. $article_id = $_GET['id'];
  13.  
  14. if( ! is_numeric($article_id) )
  15.   die('invalid article id');
  16.  
  17. $query = "SELECT * FROM `comments` WHERE `articleid` =$article_id LIMIT 0 , 30";
  18.  
  19. $comments = mysql_query($query);
  20.  
  21. echo "<h1>User Comments</h1>";
  22.  
  23. while($row = mysql_fetch_array($comments, MYSQL_ASSOC))
  24. {
  25.   $name = $row['name'];
  26.   $email = $row['email'];
  27.   $website = $row['website'];
  28.   $comment = $row['comment'];
  29.   $timestamp = $row['timestamp'];
  30.  
  31.   $name = htmlspecialchars($row['name'],ENT_QUOTES);
  32.   $email = htmlspecialchars($row['email'],ENT_QUOTES);
  33.   $website = htmlspecialchars($row['website'],ENT_QUOTES);
  34.   $comment = htmlspecialchars($row['comment'],ENT_QUOTES);
  35.  
  36.   echo "  <div style='margin:30px 0px;'>
  37.      Name: $name<br />
  38.      Email: $email<br />
  39.      Website: $website<br />
  40.      Comment: $comment<br />
  41.      Timestamp: $timestamp
  42.    </div>
  43.  ";
  44. }
  45.  
  46. mysql_close($con);
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement