Advertisement
Guest User

getalldrivers.php

a guest
Apr 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "127.0.0.1:8889";
  4. $username = "testuser";
  5. $password = "password";
  6. $databasename = "ferraridb";
  7. $databaseport = "8889";
  8.  
  9. //Create the connection
  10. $conn = mysqli_connect("$servername","$username","$password","$databasename");
  11.  
  12. //Check the connection
  13. if (mysqli_connect_errno())
  14. {
  15. die("Connection to database failed: " . mysqli_connect_error());
  16. }
  17.  
  18. //Ensure the character set returned from the query is in UTF8
  19. if (!mysqli_set_charset($conn, "utf8")) {
  20. printf("Error loading character set utf8: %s\n", mysqli_error($conn));
  21. exit();
  22. }
  23.  
  24. //Perform the query
  25. $result = mysqli_query($conn, "SELECT * FROM pilottable");
  26.  
  27. //Test the result returned and do processing
  28. $output = array();
  29. if (mysqli_num_rows($result)>0)
  30. {
  31.  
  32. while ($row = mysqli_fetch_assoc($result))
  33. {
  34. $output[] = $row;
  35. }
  36. }
  37. else
  38. {
  39. echo "No results obtained from query!";
  40. }
  41.  
  42. //Encode the response as a JSON array
  43. echo json_encode($output);
  44.  
  45. //Close the connection:
  46. mysqli_close($conn);
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement