Learning PHP and MySQL

Example 12-2 Dropping the purchases table in drop.php

<?php require_once('db_login.php'); require_once('DB.php');
$connection  =  DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
if  (
DB::isError($connection)){
die  ("Could  not  connect  to  the  database:  <br  />".  DB::errorMessage($connection));
}
$query  
=  "DROP  TABLE  `purchases`";
$result  =  $connection->query($query);
if  (
DB::isError($result)){
die("Could  not  query  the  database:  <br  />".  $query."  ".DB::errorMessage($result));
}
echo  "Table  dropped  successfully!";
$connection->disconnect();
?>

Example 12-2 returns:

Table dropped successfully!

Posted by on 09/25 at 10:51 AM

Next entry: Example 12-3 Using a predefined INSERT statement in insert.php

Previous entry: Example 12-1 Creating a table from a PHP page in create_table.php

<< Back to main