Jump to content

[SOLVED] Copy Tables To New Database


a1amattyj

Recommended Posts

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

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.