Advertisement
Guest User

D0018E Grupp 24

a guest
Nov 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.     <title>Today&rsquo;s Date</title>
  5.     <meta http-equiv="content-type"
  6.           content="text/html; charset=utf-8"/>
  7. </head>
  8. <body>
  9. <p>Today&rsquo;s date (according to this web server) is
  10.     <?php
  11.  
  12.     echo date('l, F dS Y.'), "<br>";
  13.     ?>
  14.  
  15.     <?php
  16.  
  17.         $servername = "localhost";
  18.         $username = "test";
  19.         $password = "test";
  20.         $dbname = "test";
  21.  
  22.         try {
  23.         $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  24.         // set the PDO error mode to exception
  25.         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  26.         echo "Connected successfully to mysql", "<br>";
  27.         //do stuff here?
  28.  
  29.             // sql to create table
  30.             $sql = "CREATE TABLE Test (
  31.            id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  32.            firstname VARCHAR(30) NOT NULL,
  33.            lastname VARCHAR(30) NOT NULL,
  34.            email VARCHAR(50),
  35.            reg_date TIMESTAMP
  36.            )";
  37.  
  38.             // use exec() because no results are returned
  39.             $conn->exec($sql);
  40.             echo "Table Test created successfully";
  41.  
  42.  
  43.         }
  44.         catch(PDOException $e)
  45.         {
  46.             echo "Connection failed: " . $e->getMessage(), "<br>";
  47.         }
  48.  
  49.         //Ends connection
  50.         $conn = null;
  51.  
  52.     ?>
  53.  
  54. </p>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement