[Solved] Parse xml-file and insert into mysql database


The place of mysql_query isn`t correct. You must insert records in loop:

foreach ($xml as $syn) 
{
    $w1 = $syn->w1;  
    $w2 = $syn->w2;  

    $sql    = "INSERT INTO db_name (w1, w2) VALUES ('$w1','$w2')";
    $query  = mysql_query($sql);

    if (!$query)
    {
        echo ('Error: ' . mysql_error());
    }
    else 
    {
        echo "Record added";
    }
}
mysql_close($con);

3

solved Parse xml-file and insert into mysql database