jakebur01 Posted March 11, 2008 Share Posted March 11, 2008 I am having trouble getting my table to drop and then create a new table based on another. $connect = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($db_name)or die("Couldn't select"); // Empty table $query = "DROP TABLE IF EXISTS `jhearnsberger.books_copy`"; mysql_query($query); $query = "CREATE TABLE IF NOT EXISTS `jhearnsberger.books_copy` SELECT * FROM `jhearnsberger.books`"; mysql_query($query); $query = "DELETE FROM $db_name.$destable"; $result = mysql_query($query)or die("Couldn't delete"); // do the data import $query = "load data infile \"$source_file\" INTO TABLE $destable FIELDS TERMINATED BY '|'"; $result = mysql_db_query($db_name, $query, $connect) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/95670-table-not-copying/ Share on other sites More sharing options...
Psycho Posted March 11, 2008 Share Posted March 11, 2008 And, what errors are you receiveg, if any. Which process does not execute? You should add error handling at every DB action. <?php $connect = mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error()); mysql_select_db($db_name)or die("Couldn't select") or die(mysql_error()); // Empty table $query = "DROP TABLE IF EXISTS `jhearnsberger.books_copy`"; mysql_query($query) or die($query."<br>".mysql_error()); $query = "CREATE TABLE IF NOT EXISTS `jhearnsberger.books_copy` SELECT * FROM `jhearnsberger.books`"; mysql_query($query) or die($query."<br>".mysql_error()); $query = "DELETE FROM $db_name.$destable"; mysql_query($query) or die($query."<br>".mysql_error()); // do the data import $query = "load data infile \"$source_file\" INTO TABLE $destable FIELDS TERMINATED BY '|'"; mysql_db_query($db_name, $query, $connect) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/95670-table-not-copying/#findComment-489821 Share on other sites More sharing options...
jakebur01 Posted March 11, 2008 Author Share Posted March 11, 2008 no errors returned, the first 2 querys deleting, creating, and copying the table is not executing - the one before dataloadinfile and dataloadinfile themselves are executing Quote Link to comment https://forums.phpfreaks.com/topic/95670-table-not-copying/#findComment-489826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.