SHARE
TWEET

Untitled

a guest Jun 8th, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <title>MySQL Test Page</title>
  4. </head>
  5.  
  6. <body>
  7.  
  8. <pre>
  9. <?php
  10.  
  11. $host = "";
  12. $user = "";
  13. $password = "";
  14. $db = "";
  15.  
  16. $table = "supporttest";
  17.  
  18. $link = mysql_connect($host, $user, $password)
  19.     or die ("Could not connect: " .mysql_error());
  20. echo "Opened link as user $user.\n";
  21. mysql_select_db($db, $link)
  22.     or die ("Could not select db: " . mysql_error());
  23. echo "Selected $db.\n";
  24.  
  25. $query = "CREATE TABLE $table (name VARCHAR(20))";
  26. mysql_query($query, $link)
  27.         or die("Could not create table $table: " . mysql_error());
  28. echo "Created a test table.\n";
  29.  
  30. $query = "INSERT INTO $table VALUES ('test')";
  31. mysql_query($query, $link)
  32.         or die("Could not insert row into table: " . mysql_error());
  33. echo "Inserted a row into $table table.\n";
  34.  
  35. $query = "UPDATE $table SET name='test2'";
  36. mysql_query($query, $link)
  37.         or die("Could not UPDATE table: " . mysql_error());
  38. echo "Used UPDATE to modify table.\n";
  39.  
  40. $query = "SELECT * FROM $table";
  41. $result = mysql_query($query, $link)
  42.         or die("Could not run SELECT query: " . mysql_error());
  43. $row = mysql_fetch_assoc($result);
  44. echo "Retrieved word \"{$row['name']}\" from test table by SELECT.\n";
  45.  
  46. $query = "DELETE FROM $table";
  47. mysql_query($query, $link)
  48.         or die("Could not use DELETE to empty table: " . mysql_error());
  49. echo "Used DELETE to empty table.\n";
  50.  
  51. $query = "DROP TABLE $table";
  52. mysql_query($query, $link)
  53.         or die("Could not drop $table table: " .mysql_error());
  54. echo "Dropped $table table.\n";
  55.  
  56.  
  57. mysql_close($link);
  58. echo "Closed link.\n";
  59.  
  60. ?>
  61. </pre>
  62. </body>
  63.  
  64. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top