Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "127.0.0.1:8889";
- $username = "testuser";
- $password = "password";
- $databasename = "ferraridb";
- $databaseport = "8889";
- //Create the connection
- $conn = mysqli_connect("$servername","$username","$password","$databasename");
- //Check the connection
- if (mysqli_connect_errno())
- {
- die("Connection to database failed: " . mysqli_connect_error());
- }
- //Ensure the character set returned from the query is in UTF8
- if (!mysqli_set_charset($conn, "utf8")) {
- printf("Error loading character set utf8: %s\n", mysqli_error($conn));
- exit();
- }
- //Perform the query
- $result = mysqli_query($conn, "SELECT * FROM pilottable");
- //Test the result returned and do processing
- $output = array();
- if (mysqli_num_rows($result)>0)
- {
- while ($row = mysqli_fetch_assoc($result))
- {
- $output[] = $row;
- }
- }
- else
- {
- echo "No results obtained from query!";
- }
- //Encode the response as a JSON array
- echo json_encode($output);
- //Close the connection:
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement