a1amattyj Posted July 14, 2009 Share Posted July 14, 2009 Hi, Trying to copy tables from one database to another. Already connected to the second database, server_mybb2. Old tables exist in table server_mybb $tableprefix = "9thedevil9"; $old_prefix = $tableprefix .'_mybb_'; $result = mysql_query("SHOW TABLES IN `server_mybb` LIKE '".$old_prefix."%';"); while ($record = mysql_fetch_array($result)) { $oldname = $record[0]; mysql_query("CREATE TABLE ".$oldname." LIKE `server_mybb`.".$oldname.""); echo mysql_error(); mysql_query("INSERT INTO ".$oldname." SELECT * FROM `server_mybb`.".$oldname.""); echo mysql_error(); echo $oldname . "<br /><br /><br />"; } I get errors for every table: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.9thedevil9_mybb_adminlog' at line 1 Thank you Link to comment https://forums.phpfreaks.com/topic/165898-solved-copy-tables-to-new-database/ Share on other sites More sharing options...
trq Posted July 14, 2009 Share Posted July 14, 2009 None of those sql statement are remotely valid. Id suggest you look into exporting and importing an sql dump from mysql. Link to comment https://forums.phpfreaks.com/topic/165898-solved-copy-tables-to-new-database/#findComment-875051 Share on other sites More sharing options...
a1amattyj Posted July 14, 2009 Author Share Posted July 14, 2009 Fixed, just had to remove the ` around the database name. Link to comment https://forums.phpfreaks.com/topic/165898-solved-copy-tables-to-new-database/#findComment-875053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.