Jump to content

DROP TABLE not working in PHP


justin7410

Recommended Posts


//CHECK TO SEE IF TABLE ALREADY EXISTS TO THE DATE
if($TABLE_NAME == $date){


// IF EXISTS THEN DROP THE TABLE
echo 'THIS DATE ALREADY EXISTS <br>';

$drop_table = "DROP TABLE` " .$date."`";


mysql_query($drop_table);


echo '<h4>THE TABLE HAS BEEN DROPPED</h4><h5>NOW SELECT THE FILE YOU WANT TO CREATE</h5>';




}
else{
// CREATE THE NEW TABLE


$create_table = "CREATE TABLE `".$date."` (
 `entry_id` int(11) NOT NULL,
 `transaction_id` varchar(55) NOT NULL,
 `name` varchar(255) character set latin1 default NULL,
 `price` varchar(11) character set latin1 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8";


mysql_query($create_table);
echo 'NEW TABLE HAS BEEN CREATED PLEASE MOVE TO NEXT STEP';


} $run_q = mysql_query($create_table); 


$return =  '<h4>FILE THAT YOU SELECTED:</h4>' . $_FILES['file']['name'];


$file = $_FILES['file']['tmp_name'];


$handle = fopen($file,"r");


while(($fileop = fgetcsv($handle,1000,",")) !== false){


$name   = $fileop[0];
$price   = $fileop[1];
$t_id   = $fileop[2];
$ship_method   = '';
$cc    = '';
$address = '';
$city = '';
$state    = '';
$cc    = '';
$email = '';
$p_name = '';
$p_quantity  = '';
$total = '';
$id = '';
$date = '';

}

I can't seem to get the DROP TABLE query to execute through PHP. It is not a multiple query

 

 

or anything that would create confusion, and when imputed into SQL directly fire correctly.

 

Any suggestions ?

Link to comment
https://forums.phpfreaks.com/topic/287016-drop-table-not-working-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.