Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = "mysql"; # MySQL server ip or domain name
- $user = "root"; # User for MySQL connection
- $password = "Passw0rd"; # Password for MySQL user
- $db = "sqli"; # Database to use
- # Open a new connection to the MySQL server
- $conn = mysqli_connect($server, $user, $password, $db);
- # If connection can't be openned
- # Get latest error message
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- # Construct SQL
- $sql = "SELECT id,value FROM sqli WHERE id = " . $_GET["id"];
- $sql = mysqli_real_escape_string($conn,$sql);
- # Perform query against the database
- $result = mysqli_query($conn, $sql);
- # fetch rows from our result untill NULL
- while($row = mysqli_fetch_assoc($result)) {
- # print value from from row
- echo $row["value"] . "<br>";
- }
- # Close the database connection
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement