Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //1. Database conecction
- $dbhost = "localhost";
- $dbuser = "professor_rauch";
- $dbpass = "password";
- $dbname = "untitled_DB";
- $connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
- //Test is connection works
- if(mysqli_connect_errno()){
- die("connection failed" . mysqli_connect_error() . "(". mysqli_connect_errno() .")");
- }
- ?>
- <?php
- //2. Perform query
- $query = "SELECT * FROM table_name";
- $result = mysqli_query($connection, $query);
- //test if query error
- if(!$result){
- die("query failed");
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>database</title>
- </head>
- <body>
- </body>
- </html>
- <?php
- //5. Close the connection
- mysqli_close($connection);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement