Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Today’s Date</title>
- <meta http-equiv="content-type"
- content="text/html; charset=utf-8"/>
- </head>
- <body>
- <p>Today’s date (according to this web server) is
- <?php
- echo date('l, F dS Y.'), "<br>";
- ?>
- <?php
- $servername = "localhost";
- $username = "test";
- $password = "test";
- $dbname = "test";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully to mysql", "<br>";
- //do stuff here?
- // sql to create table
- $sql = "CREATE TABLE Test (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- firstname VARCHAR(30) NOT NULL,
- lastname VARCHAR(30) NOT NULL,
- email VARCHAR(50),
- reg_date TIMESTAMP
- )";
- // use exec() because no results are returned
- $conn->exec($sql);
- echo "Table Test created successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage(), "<br>";
- }
- //Ends connection
- $conn = null;
- ?>
- </p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement