Guest User

Untitled

a guest
May 29th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. <html>
  2. <head><title>Database Connection</title></head>
  3.  
  4. <body bgcolor=lightblue>
  5.  
  6. <?php
  7.  
  8. $dbHost = "localhost";
  9. $dbUser = "smundy@usieagles.org";
  10. $dbPassword = "password";
  11. $dbName = "manufacturing";
  12. $tableName = "items";
  13.  
  14. $DBConnection = @mysqli_connect($dbHost, $dbUser, $dbPassword) or die ("Error connecting to mySQL");
  15.  
  16. if (! $DBConnection)
  17. {
  18. echo "<p> The database server is not available.</p>";
  19. }
  20. else
  21. {
  22. echo "<p> Successfully connected to the database server.</p>";
  23. }
  24.  
  25. $dbName = "manufacturing";
  26. mysqli_select_db($DBConnection, $dbName);
  27.  
  28. $createTable = FALSE;
  29.  
  30. if (! @mysqli_select_db($DBConnection, $dbName))
  31. {
  32. echo "<p> Database -", "$dbName", "- not found.</p>";
  33.  
  34. $SQLstring1 = "CREATE DATABASE manufacturing";
  35. echo "$SQLstring1";
  36.  
  37. $QueryResult = @mysqli_query($DBConnection, $SQLstring1)
  38. Or die("<p>Unable to create the manufacturing database.</p>"
  39. . "<p>Error code " . mysqli_errno($DBConnection)
  40. . ": " . mysqli_error($DBConnection)) . "</p>";
  41.  
  42. @mysqli_select_db($DBConnection, $dbName);
  43. $createTable = TRUE;
  44.  
  45. }
  46. else
  47. {
  48. echo "<p> Database -", "$dbName", "- found.</p>";
  49. }
  50.  
  51. if ($createTable)
  52. {
  53. $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))";
  54. echo "$SQLstring2";
  55. $QueryResult = @mysqli_query($DBConnection, $SQLstring2)
  56. Or die("<p>Unable to create the items table.</p>"
  57. . "<p>Error code " . mysqli_errno($DBConnection)
  58. . ": " . mysqli_error($DBConnection)) . "</p>";
  59. echo "<p>Successfully created the items table.</p>";
  60. }
  61.  
  62. ?>
  63.  
  64. <H5><A HREF="Manufacturing Data System.HTML">Main Page</A><H5>
  65.  
  66. </body>
  67. </html>
Add Comment
Please, Sign In to add comment