Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>MySQL Test Page</title>
- </head>
- <body>
- <pre>
- <?php
- $host = "";
- $user = "";
- $password = "";
- $db = "";
- $table = "supporttest";
- $link = mysql_connect($host, $user, $password)
- or die ("Could not connect: " .mysql_error());
- echo "Opened link as user $user.\n";
- mysql_select_db($db, $link)
- or die ("Could not select db: " . mysql_error());
- echo "Selected $db.\n";
- $query = "CREATE TABLE $table (name VARCHAR(20))";
- mysql_query($query, $link)
- or die("Could not create table $table: " . mysql_error());
- echo "Created a test table.\n";
- $query = "INSERT INTO $table VALUES ('test')";
- mysql_query($query, $link)
- or die("Could not insert row into table: " . mysql_error());
- echo "Inserted a row into $table table.\n";
- $query = "UPDATE $table SET name='test2'";
- mysql_query($query, $link)
- or die("Could not UPDATE table: " . mysql_error());
- echo "Used UPDATE to modify table.\n";
- $query = "SELECT * FROM $table";
- $result = mysql_query($query, $link)
- or die("Could not run SELECT query: " . mysql_error());
- $row = mysql_fetch_assoc($result);
- echo "Retrieved word \"{$row['name']}\" from test table by SELECT.\n";
- $query = "DELETE FROM $table";
- mysql_query($query, $link)
- or die("Could not use DELETE to empty table: " . mysql_error());
- echo "Used DELETE to empty table.\n";
- $query = "DROP TABLE $table";
- mysql_query($query, $link)
- or die("Could not drop $table table: " .mysql_error());
- echo "Dropped $table table.\n";
- mysql_close($link);
- echo "Closed link.\n";
- ?>
- </pre>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement