daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Aug 13th, 2016 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $name = '';
  3. $id = '';
  4. if (isset($_GET['name'])) {
  5.     $name = $_GET['name'];
  6. }else if(isset($_GET['id'])){
  7.         $id = $_GET['id'];
  8. }
  9. //--------------------------------------------------------------------------
  10.   // Example php script for fetching data from mysql database
  11.   //--------------------------------------------------------------------------
  12. $servername = "localhost";
  13. $username = "root";
  14. $password = "";
  15. $dbname = "AWS";
  16. $tableName = "aws_instances";
  17.   //--------------------------------------------------------------------------
  18.   // 1) Connect to mysql database
  19.   //--------------------------------------------------------------------------
  20. $link = mysqli_connect($servername,$username,$password,$dbname);
  21. if (!$link) {
  22.     echo "Error: Unable to connect to MySQL." . PHP_EOL;
  23.     echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  24.     echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
  25.     exit;
  26. }
  27.  
  28.   //--------------------------------------------------------------------------
  29.   // 2) Query database for data
  30.   //--------------------------------------------------------------------------
  31. if($name != ''){
  32. $sql = "SELECT * FROM `aws_instances` WHERE `Name` ='$name'";
  33. }else {
  34. $sql = "SELECT * FROM `aws_instances` WHERE `InstanceId` ='$id'";
  35. }
  36. $result = mysql_query ($sql) or die (mysql_error ());
  37. while ($row = mysql_fetch_array ($result)){
  38. echo $row['Name'];
  39. }
  40. mysqli_close($link);
  41.  
  42. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top