Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Database Connection</title></head>
- <body bgcolor=lightblue>
- <?php
- $dbHost = "localhost";
- $dbUser = "smundy@usieagles.org";
- $dbPassword = "password";
- $dbName = "manufacturing";
- $tableName = "items";
- $DBConnection = @mysqli_connect($dbHost, $dbUser, $dbPassword) or die ("Error connecting to mySQL");
- if (! $DBConnection)
- {
- echo "<p> The database server is not available.</p>";
- }
- else
- {
- echo "<p> Successfully connected to the database server.</p>";
- }
- $dbName = "manufacturing";
- mysqli_select_db($DBConnection, $dbName);
- $createTable = FALSE;
- if (! @mysqli_select_db($DBConnection, $dbName))
- {
- echo "<p> Database -", "$dbName", "- not found.</p>";
- $SQLstring1 = "CREATE DATABASE manufacturing";
- echo "$SQLstring1";
- $QueryResult = @mysqli_query($DBConnection, $SQLstring1)
- Or die("<p>Unable to create the manufacturing database.</p>"
- . "<p>Error code " . mysqli_errno($DBConnection)
- . ": " . mysqli_error($DBConnection)) . "</p>";
- @mysqli_select_db($DBConnection, $dbName);
- $createTable = TRUE;
- }
- else
- {
- echo "<p> Database -", "$dbName", "- found.</p>";
- }
- if ($createTable)
- {
- $SQLstring2 = "CREATE TABLE items (itemNumber VARCHAR(12), itemDescription VARCHAR(35), warehouseLocation VARCHAR(10), sellingPrice DOUBLE (9,2), materialCost DOUBLE(9,2), laborCost DOUBLE(9,2), overheadCost DOUBLE(9,2), unitOfMeasure CHAR(2), buyerCode CHAR(1), itemClassCode CHAR(2), productCode CHAR(2), itemTypeCode INT(1), purchaseLeadTime INT(3))";
- echo "$SQLstring2";
- $QueryResult = @mysqli_query($DBConnection, $SQLstring2)
- Or die("<p>Unable to create the items table.</p>"
- . "<p>Error code " . mysqli_errno($DBConnection)
- . ": " . mysqli_error($DBConnection)) . "</p>";
- echo "<p>Successfully created the items table.</p>";
- }
- ?>
- <H5><A HREF="Manufacturing Data System.HTML">Main Page</A><H5>
- </body>
- </html>
Add Comment
Please, Sign In to add comment