script to trans. data one db to another db
Posted: Wed Jan 07, 2004 4:31 pm
I have installed a new safelist script on my domain. I have placed the tables for both in the same db. Now I need to transfer the databases.
I have written a short script for this but seems something is wrong? Can someone take a quick look to see what I have done wrong.
Thank you for your help in advance.
Old table: safe_members
New table: SP_members
Both tables in same database
--------------- Script ---------------
<?php
$db = mysql_connect("localhost", "xxxxxxxxx", "xxxxxxxxx");
mysql_select_db("xxxxxxxxx",$db);
$result = mysql_query("SELECT * FROM safe_members",$db);
while ($myrow = mysql_fetch_array($result)) {
$id = $myrow["userid"];
$Fullname = $myrow["fullname"];
$C_email = $myrow["contact"];
$S_email = $myrow["subscribe"];
$Type = $myrow["type"];
$Joindate = $myrow["joindate"];
$Points = $myrow["points"];
$Active = $myrow["VERIFIED"];
if ($Type == "FREE") {$Type == "0"};
elseif ($Type == "PRO") {Type == "1"};
elseif ($Type == "PLATINUM") {Type == "3"};
if ($Active == "VERIFIED") {$Active == "ON"} else {$Active == ""};
$sql = "INSERT INTO SP_members (username,fullname,contact_email,list_email,membership,date_joined,credits,activation) VALUES ('$id','$Fullname','$C_email','$S_email','$Type','$Joindate','$Points','$Active)";
}
?>
I have written a short script for this but seems something is wrong? Can someone take a quick look to see what I have done wrong.
Thank you for your help in advance.
Old table: safe_members
New table: SP_members
Both tables in same database
--------------- Script ---------------
<?php
$db = mysql_connect("localhost", "xxxxxxxxx", "xxxxxxxxx");
mysql_select_db("xxxxxxxxx",$db);
$result = mysql_query("SELECT * FROM safe_members",$db);
while ($myrow = mysql_fetch_array($result)) {
$id = $myrow["userid"];
$Fullname = $myrow["fullname"];
$C_email = $myrow["contact"];
$S_email = $myrow["subscribe"];
$Type = $myrow["type"];
$Joindate = $myrow["joindate"];
$Points = $myrow["points"];
$Active = $myrow["VERIFIED"];
if ($Type == "FREE") {$Type == "0"};
elseif ($Type == "PRO") {Type == "1"};
elseif ($Type == "PLATINUM") {Type == "3"};
if ($Active == "VERIFIED") {$Active == "ON"} else {$Active == ""};
$sql = "INSERT INTO SP_members (username,fullname,contact_email,list_email,membership,date_joined,credits,activation) VALUES ('$id','$Fullname','$C_email','$S_email','$Type','$Joindate','$Points','$Active)";
}
?>