Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2. $server = "mysql"; # MySQL server ip or domain name
  3. $user = "root"; # User for MySQL connection
  4. $password = "Passw0rd"; # Password for MySQL user
  5. $db = "sqli"; # Database to use
  6.  
  7. # Open a new connection to the MySQL server
  8. $conn = mysqli_connect($server, $user, $password, $db);
  9.  
  10. # If connection can't be openned
  11. # Get latest error message
  12. if (!$conn) {
  13.   die("Connection failed: " . mysqli_connect_error());
  14. }
  15.  
  16. # Construct SQL
  17. $sql = "SELECT id,value FROM sqli WHERE id = " . $_GET["id"];
  18. $sql = mysqli_real_escape_string($conn,$sql);
  19.  
  20. # Perform query against the database
  21. $result = mysqli_query($conn, $sql);
  22.  
  23. # fetch rows from our result untill NULL
  24. while($row = mysqli_fetch_assoc($result)) {
  25.   # print value from from row
  26.  echo $row["value"] . "<br>";
  27. }
  28.  
  29. # Close the database connection
  30. mysqli_close($conn);
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement