Trying to remove duplicate fields from Mysql database!!!!
Posted: Fri Feb 12, 2010 1:46 pm
Hello, again php technorati. I bring another one of my issues to your doorstep.
I am trying create a php script that removes duplicate Fields/Rows from MySQL db.
Here is the code:
Here is the error:
Thanks in advance
Batoe
I am trying create a php script that removes duplicate Fields/Rows from MySQL db.
Here is the code:
Code: Select all
$qry = "select email from mail_list_2";
$db=query( $qry );
while( $data = $db->fetchArray() ) {
$qry1 = "select * from mail_list_2 where email='".$data['email']."' ";
$db1=query( $qry1 );
if($db1->numRows() > 1)
{
$check=0;
while( $data1 = $db1->fetchArray() ) {
if($check > 0)
{
####### add delete query here
$sql_del="delete from mail_list_2 where email=".$data['email'];
$db->query( $sql_del );
}
$check++;
}
}
Please enlighten.Fatal error: Call to undefined function query() in *********************** on line 315
Thanks in advance
Batoe