While trying to learn about PHP and mySQL, I have created a couple of tables. I have been messing around trying to get everything to work, and now I want to clean things up and eliminate a couple of test tables. I have spent some time searching the Manual, and a Google search to no avail. I tried recreating a table over the existing one, and that did not work either--I thought it would erase/replace it. I am using PHP, if it helps.
I'm stumped. I have tried the following with and without the "'" around contacts. Any help appreciated. This runs without an error message, but the table is still there:
<?
include('config.inc.php');
mysql_pconnect($db_hostname,$db_username,$db_password) OR DIE("<b>Cannot connect to mySQL</b>";
mysql_select_db("$db_dbname" or die ("<b>Table $db_dbname does not exist</b>";
$query= "DROP TABLE [IF EXISTS] 'contacts'";
mysql_close();
?>
One of my tables I was going to drop and then remake, but decided to see if I could ADD a column. I would rather do everything in PHP, so I can learn more. Again, this did not work:
<?
include('config.inc.php');
mysql_pconnect($db_hostname,$db_username,$db_password) OR DIE("<b>Cannot connect to mySQL</b>";
mysql_select_db("$db_dbname" or die ("<b>Table $db_dbname does not exist</b>";
$query= "ALTER TABLE inventory ADD COLUMN ( date_purchased varchar(10) NOT NULL )";
mysql_close();
?>
When I print out the file with another php script, I get an error that date_purchased was not found in index2. What is index2? Is it named that because it is the second of two tables?
While I am here, let me ask about phpMyAdmin. If I wanted to use it, should I download the software and then ftp it to a subdirectory of my site? I would rather run it from there than to put Apache, php, and mySQL on my own computer. Right now, I think I am learning a lot more by trying to make everything in php, than if I used the admin software. Is that foolish?
Any help will be greatly appreciated.