hey people,
i have the following problem, i'm setting up a webshop with over 2k items and every 6months the prices are changing(wines) so i was wondering how to import an xml file into a mysql database without having to go in phpmyadmin. this because i don't want the people for who i'm making the website have access there to destroy the whole database. this is what i got so far:

<?php
	include "header.php";
?>
<br><br><br>
<h1>Database updaten</h1>
<form enctype="multipart/form-data" 
  action="import.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
  <table width="600">
  <tr>
  <td>Names file:</td>
  <td><input type="file" name="file" /></td>
  <td><input type="submit" value="Upload" /></td>
  </tr>
  </table>
  </form>
  </body>
  </html>

here i choose the file i want to import,
and then i run true the following script:

<?php
include ("header.php");
$query = "TRUNCATE TABLE  `wijnen`";
$result = mysql_query($query) or die('Error : ' . mysql_error());
$data = array();  
 function add_person( $id, $domein, $naam, $land, $streek, $substreek, $jaar, $type, $smaak, $formaat, $druivensoort, $prijsnormaal,
   $prijs6, $prijs12, $prijs24, $info, $actieid, $afbeelding, $kleur, $titel, $description, $keywords, $afbeeldingalt, $spijs, $leverancier, $levertijd )
  {
    global $data;  
     $data []= array(
  'id' => $id,
  'domein' => $domein,
  'naam' => $naam,
  'land' => $land, 
  'streek' => $streek,
  'substreek' => $substreek,
  'jaar' => $jaar,
  'type' => $type,
  'smaak' => $smaak,
  'formaat' => $formaat,
  'druivensoort' => $druivensoort,
  'prijsnormaal' => $prijsnormaal,
  'prijs6' => $prijs6,
  'prijs12' => $prijs12,
  'prijs24' => $prijs24,
  'info' => $info,
  'actieid' => $actieid,
  'afbeelding' => $afbeelding,
  'kleur' => $kleur,
  'titel' => $titel,
  'description' => $description,
  'keywords' => $keywords,
  'afbeeldingalt' => $afbeeldingalt,
  'spijs' => $spijs,
  'leverancier' => $leverancier,
  'levertijd' => $levertijd
  );
      }
         if ( $_FILES['file']['tmp_name'] )
           {
            $dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
             
              $rows = $dom->getElementsByTagName( 'Row' );
                $first_row = true;
                 foreach ($rows as $row)
                  {  if ( !$first_row )
                    {
                      $id = "";
  $domein = "";
  $naam = "";
  $land = "";
  $streek = "";
  $substreek = "";
  $jaar = "";
  $type = "";
  $smaak = "";
  $formaat = "";
  $druivensoort = "";
  $prijsnormaal = "";
  $prijs6 = "";
  $prijs12 = "";
  $prijs24 = "";
  $info = "";
  $actieid = "";
  $afbeelding = "";
  $kleur = "";
  $titel = "";
  $description = "";
  $keywords = "";
  $afbeeldingalt = "";
  $spijs = "";
  $leverancier = "";
  $levertijd = "";
                           $index = 1;
                            $cells = $row->getElementsByTagName( 'Cell' ); 
                            foreach( $cells as $cell )
                             {
                               $ind = $cell->getAttribute( 'Index' );
                                if ( $ind != null ) $index = $ind;
                                   if ( $index == 1 ) $id = $cell->nodeValue;
  if ( $index == 2 ) $domein = $cell->nodeValue;
  if ( $index == 3 ) $naam = $cell->nodeValue;
  if ( $index == 4 ) $land = $cell->nodeValue;
  if ( $index == 5 ) $streek = $cell->nodeValue;
  if ( $index == 6 ) $substreek = $cell->nodeValue;
  if ( $index == 7 ) $jaar = $cell->nodeValue;
  if ( $index == 8 ) $type = $cell->nodeValue;
  if ( $index == 9 ) $smaak = $cell->nodeValue;
  if ( $index == 10 ) $formaat = $cell->nodeValue;
  if ( $index == 11 ) $druivensoort = $cell->nodeValue;
  if ( $index == 12 ) $prijsnormaal = $cell->nodeValue;
  if ( $index == 13 ) $prijs6 = $cell->nodeValue;
  if ( $index == 14 ) $prijs12 = $cell->nodeValue;
  if ( $index == 15 ) $prijs24 = $cell->nodeValue;
  if ( $index == 16 ) $info = $cell->nodeValue;
  if ( $index == 17 ) $actieid = $cell->nodeValue;
  if ( $index == 18 ) $afbeelding = $cell->nodeValue;
  if ( $index == 19 ) $kleur = $cell->nodeValue;
  if ( $index == 20 ) $titel = $cell->nodeValue;
  if ( $index == 21 ) $description = $cell->nodeValue;
  if ( $index == 22 ) $keywords = $cell->nodeValue;
  if ( $index == 23 ) $afbeeldingalt = $cell->nodeValue;
  if ( $index == 24 ) $spijs = $cell->nodeValue;
  if ( $index == 25 ) $leverancier = $cell->nodeValue;
  if ( $index == 26 ) $levertijd = $cell->nodeValue;
  
                                        $index += 1;
                                         } 
                                         add_person( $id, $domein, $naam, $land, $streek, $substreek, $jaar, $type, $smaak, $formaat, $druivensoort, $prijsnormaal, $prijs6, $prijs12, $prijs24, $info, $actieid, $afbeelding, $kleur, $titel, $description, $keywords, $afbeeldingalt, $spijs, $leverancier, $levertijd );
                                           }
                                            $first_row = false;
                                             }
                                              }
                        foreach($data as $row) 
                        
                       { 
			$rowz = mysql_real_escape_string($row['domein']);
            mysql_query("insert into wijnen values('','$rowz','$row[naam]','$row[land]','$row[streek]','$row[substreek]','$row[jaar]','$row[type]','$row[smaak]',
			'$row[formaat]','$row[druivensoort]','$row[prijsnormaal]','$row[prijs6]','$row[prijs12]','$row[prijs24]','$row[info]','$row[actieid]','$row[afbeelding]',
			'$row[kleur]','$row[titel]','$row[description]','$row[keywords]','$row[afbeeldingalt]','$row[spijs]','$row[leverancier]','$row[levertijd]')");
              }
echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=bestandkiezen.php'>";
?>

now my problem, when i have signs like ë ï ö ü ä é í ó ú á and so on they aren't parsed into the database the correct way. anyone knows how i can solve this?

thanks for the great help :)
this solved my first problem. i'm also getting the following error:
Strict Standards: Non-static method DOMDocument::load() should not be called statically in C:\xampp\htdocs\wijnkado\administratie\import.php on line 41

i don't know if the next issue is has to do anything with this. the script imports ~185 rows in my database but after that it stops and does nothing anymore.
anyone know how i can solve this?

The error you get is a warning. See http://nl.php.net/manual/en/domdocument.load.php. More appropriate way to do this is to create a Domdocument and call its method: Doc->Load(filename);

This does not affect your 185 rows item. May you can find something in the error log of apache.

ok if its only a warning it's ok..but still can't figure out why my XML file isn't full loading in :S
does anyone see something i do wrong

Maybe the XML contains data that couldn't be processed.

Hello, I don't see any obviously wrong. Maybe you can split up the problem into parts. First try to dump all row on to screen. If the script can print all rows onto screen (you can use print var_export($var, true) see http://nl2.php.net/manual/en/function.var-export.php then something may be wrong with uploading it into the database. If you use PHP 5 you can make use of the try-catch-finally struct to catch errors. When catched you can print the message to screen. Alternatively you can setup your environment to debug the code.

Good luck!

i found out the xml is ok, i printed all the data on my webpage and that's working fine. it just doesn't parse all rows, anyone has a solution for this?
maby place a break between the sql queries? if that's possible how do i do that?

also figured out that's not working :S
anyone has any idea's left?

I just looked at your code. Why do you first put all data into an array an afterwards loop through the array to insert the data into the database? Why don't you directly insert these data? Instead of add_person() you creat a function insert_db

function insert_db(......)
{
    try
    {
        $sql = "insert into .....";
        $result = mysql_query(mysql_real_escape_string($sql));
        if (!$result)
        {
            print 'Invalid query: ' . mysql_error();
        }
    }
    catch(....)
    {
         ......
    }
}

i just made a log from the errors:

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: Query was empty

Invalid query: 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 '1' at line 1

Invalid query: 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 '1' at line 1


but the problem is when i have this error:
Invalid query: 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 '1' at line 1
it enters all the data correctly.but it also has some empty queries :S how it this possible when they are well formed in the table i print?

could you be a litle more specific how to preform this?
not that great with php...
where should i put this code?

I just looked at your code. Why do you first put all data into an array an afterwards loop through the array to insert the data into the database? Why don't you directly insert these data? Instead of add_person() you creat a function insert_db

function insert_db(......)
{
    try
    {
        $sql = "insert into .....";
        $result = mysql_query(mysql_real_escape_string($sql));
        if (!$result)
        {
            print 'Invalid query: ' . mysql_error();
        }
    }
    catch(....)
    {
         ......
    }
}

I hope this will help you somewhat. Make sure you can see the query so you can see what's wrong with is.

<?php
include ("header.php");

main();
//to find out the problem leave this
//echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=bestandkiezen.php'>";
exit();


function main()
{
    try
    { 
        $query = "TRUNCATE TABLE  `wijnen`";
        if( !doQuery($query) ) die();
    
        $dom = new DOMDocument();
        $dom->Load($_FILES['file']['tmp_name']);
        
        $rows = $dom->getElementsByTagName( 'Row' );
        $first_row = true;
        foreach ($rows as $row)
        {  
            if ( !$first_row )
            {
                doQuery(GetRowQuery($row));
            }
        }
    }
    catch(Exception $e)
    {
        //to find out the problem echo the lines, for production use e.g. a logfile
        echo "Exception catched: " . $e->getMessage() . "<br/>"
    }
}

function doQuery($sql)
{
    $return = false;
    try
    {
        $result = mysql_query(mysql_real_escape_string($sql);
        if( !$result)
        {
            //to find out the problem echo the lines, for production use e.g. a logfile
            echo "Invalid query: " . mysql_error()  . "<br/>";
            echo "Query [$sql]<<br/>";
        }
        else
        {
            $return = true;
        } 
    }
    catch( Exception $e)
    {
        //to find out the problem echo the lines, for production use e.g. a logfile
        echo "Exception catched: " . $e->getMessage() . "<br/>"
        echo "Query [$sql]<<br/>";
    }
    
    return $return;
}

function getRowQuery( $row )
{
    $data = array();
    
    $index = 0
    //get data from the cells
    $cells = $row->getElementsByTagName( 'Cell' ); 
    foreach( $cells as $cell )
    {
        $ind = $cell->getAttribute( 'Index' );

        if ( $ind != null ) 
        {
            $index = $ind;
        }
        else
        {
            $index++;
        }
        
        switch( $index)
        {
            case 1:
                //'domein' should be a column name in the database
                $data['domein'] = $cell->nodeValue;
                break;
            case 2: 
                break;
            case    
                ...
            case 26:
                break;
            default
                echo "This wasn't really expected";
        }
    }
    
    //create the query with the available data
    $columns = "";
    $values = "";
    foreach($data as $key => $value)
    {
        $columns .= ", " . $key;
        $values .= ", '" . $value . "'";
    }
    
    return "insert into wijnen (" . substr($columns, 2) . ") values (" . substr($values, 2) . ")"; 
}

?>
commented: thanks alot :) +3

thanks alot but this is not working, got all the syntax errors out and it's looking just fine :)
but when i use the code its not sending any data to the database and no errors :S

<?php
include ("header.php");
 
main();
//to find out the problem leave this
//echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=bestandkiezen.php'>";
exit();
 
 
function main()
{
    try
    { 
        $query = "TRUNCATE TABLE  `wijnen`";
        if( !doQuery($query) ) die();
 
        $dom = new DOMDocument();
        $dom->Load($_FILES['file']['tmp_name']);
 
        $rows = $dom->getElementsByTagName( 'Row' );
        $first_row = true;
        foreach ($rows as $row)
        {  
            if ( !$first_row )
            {
                doQuery(GetRowQuery($row));
            }
        }
    }
    catch(Exception $e)
    {
        //to find out the problem echo the lines, for production use e.g. a logfile
        echo "Exception catched: " . $e->getMessage() . "<br/>";
    }
}
 
function doQuery($sql)
{
    $return = false;
    try
    {
        $result = mysql_query(mysql_real_escape_string($sql));
        if( !$result)
        {
            //to find out the problem echo the lines, for production use e.g. a logfile
            echo "Invalid query: " . mysql_error()  . "<br/>";
            echo "Query [$sql]<<br/>";
        }
        else
        {
            $return = true;
        } 
    }
    catch( Exception $e)
    {
        //to find out the problem echo the lines, for production use e.g. a logfile
        echo "Exception catched: " . $e->getMessage() . "<br/>";
        echo "Query [$sql]<<br/>";
    }
 
    return $return;
}
 
function getRowQuery( $row )
{
    $data = array();
 
    $index = 0;
    //get data from the cells
    $cells = $row->getElementsByTagName( 'Cell' ); 
    foreach( $cells as $cell )
    {
        $ind = $cell->getAttribute( 'Index' );
 
        if ( $ind != null ) 
        {
            $index = $ind;
        }
        else
        {
            $index++;
        }
 
        switch( $index)
        {
            case 1:
                //'domein' should be a column name in the database
                $data['id'] = $cell->nodeValue;
                break;
            case 2: 
				$data['domein'] = $cell->nodeValue;
                break;
            case 3:   
				$data['naam'] = $cell->nodeValue;
                break;
			case 4:    
				$data['land'] = $cell->nodeValue;
                break;
			case 5:    
				$data['streek'] = $cell->nodeValue;
                break;
			case 6:   
				$data['substreek'] = $cell->nodeValue;
                break; 
			case 7:    
                $data['jaar'] = $cell->nodeValue;
                break;
			case 8:    
                $data['type'] = $cell->nodeValue;
                break;
			case 9:    
                $data['smaak'] = $cell->nodeValue;
                break;
			case 10:    
                $data['formaat'] = $cell->nodeValue;
                break;
			case 11:    
                $data['druivensoort'] = $cell->nodeValue;
                break;
			case 12:    
                $data['prijsnormaal'] = $cell->nodeValue;
                break;
			case 13:    
                $data['prijs6'] = $cell->nodeValue;
                break;
			case 14:    
                $data['prijs12'] = $cell->nodeValue;
                break;
			case 15:    
                $data['prijs24'] = $cell->nodeValue;
                break;
			case 16:    
                $data['info'] = $cell->nodeValue;
                break;
			case 17:    
                $data['actieid'] = $cell->nodeValue;
                break;
			case 18:    
                $data['afbeelding'] = $cell->nodeValue;
                break;
			case 19:    
                $data['kleur'] = $cell->nodeValue;
                break;
			case 20:    
                $data['titel'] = $cell->nodeValue;
                break;
			case 21:    
                $data['description'] = $cell->nodeValue;
                break;
			case 22:    
                $data['keywords'] = $cell->nodeValue;
                break;
			case 23:    
                $data['afbeeldingalt'] = $cell->nodeValue;
                break;
			case 24:    
                $data['spijs'] = $cell->nodeValue;
                break;
			case 25:    
                $data['leverancier'] = $cell->nodeValue;
                break;
            case 26:
                $data['levertijd'] = $cell->nodeValue;
                break;
            default:
                print "This wasn't really expected";
        }
    }
 
    //create the query with the available data
    $columns = "";
    $values = "";
    foreach($data as $key => $value)
    {
        $columns .= ", " . $key;
        $values .= ", '" . $value . "'";
    }
	
    return "insert into wijnen (" . substr($columns, 2) . ") values (" . substr($values, 2) . ")"; 
}
?>

That's right. My fault: forgot to set first_row false

foreach ($rows as $row)
        {  
            if ( !$first_row )
            {
                doQuery(GetRowQuery($row));
                /**
                 * what you can do to echo the query is this:
                 * $query = GetRowQuery($row);
                 * echo $query;
                 * doQuery($query);
                 **/
            }
            else
            {
                $first_row = false;
            }
        }

ok fixed that, thanks alot :)
but now i still have the same problem as before. it solved nothing :S
for some reason there are still fields from my xml that aren't getting parsed to mysql, and i'm almost sure it's not about the xml because i can print them, here is an example of my rows that isn't parsed correctly with the following error: Invalid query: Query was empty

<Row ss:AutoFitHeight="0">
    <Cell><Data ss:Type="Number">2</Data></Cell>
    <Cell><Data ss:Type="String">Bodega Sottano</Data></Cell>
    <Cell><Data ss:Type="String">Sottano Merlot  </Data></Cell>
    <Cell><Data ss:Type="String">Argentinië</Data></Cell>
    <Cell><Data ss:Type="String">Mendoza</Data></Cell>
    <Cell><Data ss:Type="String">NULL</Data></Cell>
    <Cell><Data ss:Type="Number">2010</Data></Cell>
    <Cell><Data ss:Type="String">droge rode gekruide wijn</Data></Cell>
    <Cell><Data ss:Type="String">wijn met warme aroma's en veel fruit en mooie kruidigheid</Data></Cell>
    <Cell><Data ss:Type="Number">75</Data></Cell>
    <Cell><Data ss:Type="String">NULL</Data></Cell>
    <Cell><Data ss:Type="String">8,95</Data></Cell>
    <Cell><Data ss:Type="String">7,45</Data></Cell>
    <Cell><Data ss:Type="String">6,95</Data></Cell>
    <Cell><Data ss:Type="String">6,45</Data></Cell>
    <Cell><Data ss:Type="String">Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.</Data></Cell>
    <Cell><Data ss:Type="String">NULL</Data></Cell>
    <Cell><Data ss:Type="String">../uploads/sottano merlot.jpg</Data></Cell>
    <Cell><Data ss:Type="String">Rood</Data></Cell>
    <Cell><Data ss:Type="String">Sottano Merlot  </Data></Cell>
    <Cell><Data ss:Type="String">Sottano Merlot  </Data></Cell>
    <Cell><Data ss:Type="String">Sottano Merlot  </Data></Cell>
    <Cell><Data ss:Type="String">Sottano Merlot  </Data></Cell>
    <Cell><Data ss:Type="String">roodvlees, wild, kazen</Data></Cell>
    <Cell><Data ss:Type="String">LFE</Data></Cell>
    <Cell><Data ss:Type="String">NULL</Data></Cell>
   </Row>

Is the query really empty? How does the query look like?
Can you see what $cell->nodeValue; contains? Does it contain any value? Or do you need to use the Data-node of $cell first? Try to get clear what happens when the query is created. Echo information that can help you getting this clear.
Good luck.

Invalid query: Query was empty
Query []<
Invalid query: Query was empty

Invalid query: Query was empty
Query []<
1Invalid query: 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 '1' at line 1

thats what i get from the echo
so the query is realy empty... :S
first you see is this:

if (!$result)
        {
        print 'Invalid query: ' . mysql_error();
        echo "<br>";
        echo "<br>";
        }

and then i echo the query:

$sql = mysql_query("insert into wijnen (" . substr($columns, 2) . ") values (" . substr($values, 2) . ")"); 
echo $sql;

so nothing strange about this and when i get the error: 1Invalid query: 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 '1' at line 1
everything is going fine...

echo $cell->nodeValue;
    $sql = mysql_query("insert into wijnen (" . substr($columns, 2) . ") values (" . substr($values, 2) . ")"); 
	echo $sql;
	$result = mysql_query(mysql_real_escape_string($sql));
	if (!$result)
			{
            print 'Invalid query: ' . mysql_error();
			echo "<br>";
			echo "<br>";
			}

this is what i'm using in total: with the following result:

levertijd1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
NULLInvalid query: Query was empty

it's just a part of the errors..

Add "echo var_export($data, true);" between the 2 foreaches in getRowQuery so you can see what the array contains.
And echo $columns and $values so you can see what the contain.

Somehow it appears the function getRowQuery returns unexpectedly.

done and this is the result:

array ( 'id' => 'id', 'domein' => 'domein', 'naam' => 'naam', 'land' => 'land', 'streek' => 'streek', 'substreek' => 'substreek', 'jaar' => 'jaar', 'type' => 'type', 'smaak' => 'smaak', 'formaat' => 'formaat', 'druivensoort' => 'druivensoort', 'prijsnormaal' => 'prijsnormaal', 'prijs6' => 'prijs6', 'prijs12' => 'prijs12', 'prijs24' => 'prijs24', 'info' => 'info', 'actieid' => 'actieid', 'afbeelding' => 'afbeelding', 'kleur' => 'kleur', 'titel' => 'titel', 'description' => 'description', 'keywords' => 'keywords', 'afbeeldingalt' => 'afbeeldingalt', 'spijs' => 'spijs', 'leverancier' => 'leverancier', 'levertijd' => 'levertijd', )levertijd1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
array ( 'id' => '1', 'domein' => 'Bodega Sottano', 'naam' => 'Sottano Judas Malbec', 'land' => 'Argentinië', 'streek' => 'Mendoza', 'substreek' => 'NULL', 'jaar' => '2007', 'type' => 'droge volle rode gekruide wijn', 'smaak' => 'wijn met warme aroma\'s en veel fruit en mooie kruidigheid', 'formaat' => '75', 'druivensoort' => 'NULL', 'prijsnormaal' => '54,95', 'prijs6' => '43,95', 'prijs12' => '43,45', 'prijs24' => '42,95', 'info' => 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'actieid' => 'NULL', 'afbeelding' => '../uploads/sottano judas.jpg', 'kleur' => 'Rood', 'titel' => 'Sottano Judas Malbec', 'description' => 'Sottano Judas Malbec', 'keywords' => 'Sottano Judas Malbec', 'afbeeldingalt' => 'Sottano Judas Malbec', 'spijs' => 'roodvlees, wild, kazen', 'leverancier' => 'LFE', 'levertijd' => 'NULL', )NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
array ( 'id' => '2', 'domein' => 'Bodega Sottano', 'naam' => 'Sottano Merlot ', 'land' => 'Argentinië', 'streek' => 'Mendoza', 'substreek' => 'NULL', 'jaar' => '2010', 'type' => 'droge rode gekruide wijn', 'smaak' => 'wijn met warme aromas en veel fruit en mooie kruidigheid', 'formaat' => '75', 'druivensoort' => 'NULL', 'prijsnormaal' => '8,95', 'prijs6' => '7,45', 'prijs12' => '6,95', 'prijs24' => '6,45', 'info' => 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'actieid' => 'NULL', 'afbeelding' => '../uploads/sottano merlot.jpg', 'kleur' => 'Rood', 'titel' => 'Sottano Merlot ', 'description' => 'Sottano Merlot ', 'keywords' => 'Sottano Merlot ', 'afbeeldingalt' => 'Sottano Merlot ', 'spijs' => 'roodvlees, wild, kazen', 'leverancier' => 'LFE', 'levertijd' => 'NULL', )NULL1Invalid query: 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 '1' at line 1

Invalid query: Query was empty
Query []<
array ( 'id' => '3', 'domein' => 'Bodega Sottano', 'naam' => 'Sottano Merlot/Malbec', 'land' => 'Argentinië', 'streek' => 'Mendoza', 'substreek' => 'NULL', 'jaar' => '2010', 'type' => 'droge rode wijn', 'smaak' => 'wijn met warme aroma\'s en veel fruit en mooie kruidigheid', 'formaat' => '75', 'druivensoort' => 'NULL', 'prijsnormaal' => '5,95', 'prijs6' => '4,95', 'prijs12' => '4,65', 'prijs24' => '4,35', 'info' => 'Een jonge wijn voor alledaags gebruik met een schitterende helderrode kleur. De wijn heeft aroma’s van rijp rood fruit en bosbessen. Zachte tannines en souplesse geven deze wijn een prachtige balans.', 'actieid' => 'NULL', 'afbeelding' => '../uploads/sottano merlot malbec.jpg', 'kleur' => 'Rood', 'titel' => 'Sottano Merlot/Malbec', 'description' => 'Sottano Merlot/Malbec', 'keywords' => 'Sottano Merlot/Malbec', 'afbeeldingalt' => 'Sottano Merlot/Malbec', 'spijs' => 'roodvlees, wild, kazen', 'leverancier' => 'LFE', 'levertijd' => 'NULL', )NULLInvalid query: Query was empty

Invalid query: Query was empty
Query []<
array ( 'id' => '4', 'domein' => 'Bodega Sottano', 'naam' => 'Sottano Reserva Malbec', 'land' => 'Argentinië', 'streek' => 'Mendoza', 'substreek' => 'NULL', 'jaar' => '2008', 'type' => 'droge rode gekruide wijn', 'smaak' => 'wijn met warme aroma\'s en veel fruit en mooie kruidigheid', 'formaat' => '75', 'druivensoort' => 'NULL', 'prijsnormaal' => '10,95', 'prijs6' => '8,95', 'prijs12' => '8,65', 'prijs24' => '8,35', 'info' => 'Prachtige donkerrode kleur met een goede concentratie en tonen van cassis, koffie, chocolade en specerijen, die samen zorgen voor een prachtige complexiteit. Stevig mondgevoel, vlezig met rijpe en ronde tannines en goed uitgebalanceerde houttonen.', 'actieid' => 'NULL', 'afbeelding' => '../uploads/sottano reserva malbec.jpg', 'kleur' => 'Rood', 'titel' => 'Sottano Reserva Malbec', 'description' => 'Sottano Reserva Malbec', 'keywords' => 'Sottano Reserva Malbec', 'afbeeldingalt' => 'Sottano Reserva Malbec', 'spijs' => 'roodvlees, wild, kazen', 'leverancier' => 'LFE', 'levertijd' => 'NULL', )NULLInvalid query: Query was empty

What maybe could have happened - but I 'm not sure - PHP interprets 'NULL' really for NULL and not like the text NULL. NULL . "some text" => NULL
Try to catch these 'NULL' values or avoid using them. Actually you don't need them anymore: "insert wijnen (id) values (4)" does insert NULL values for all other columns.

well i think the error is in the info field. if i replace the text in that one with NULL it's working for the most. but i posted an example that was not working. on 1 page back. and i see there is a ' in the text is there a way to filter this out or something? i thaught i already did that with the mysql_real_escape_string but maby that should already happen by reading the text from the xml...

just replaced all the NULL with 0 and still the same error. so i think it has to do with ' in the text i try to enter. how do i fix this? could you help me out with this. almost sure it's that what's messing up the import

try to proof what you're saying. With this you can see your query columns and values grow. It actually might be better to use the mysql_real_escape_string for the values only.

Nice problem! :-)

//create the query with the available data
    $columns = "";
    $values = "";
    foreach($data as $key => $value)
    {
        $columns .= ", " . $key;
        echo $columns . "<br/>";
        $values .= ", '" . $value . "'";
        echo $values . "<br/>";
    }

i just edited what you said... but still i can't see where it's going wrong :S
here is the output:

, id
, 'id'
, id, domein
, 'id', 'domein'
, id, domein, naam
, 'id', 'domein', 'naam'
, id, domein, naam, land
, 'id', 'domein', 'naam', 'land'
, id, domein, naam, land, streek
, 'id', 'domein', 'naam', 'land', 'streek'
, id, domein, naam, land, streek, substreek
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek'
, id, domein, naam, land, streek, substreek, jaar
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar'
, id, domein, naam, land, streek, substreek, jaar, type
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type'
, id, domein, naam, land, streek, substreek, jaar, type, smaak
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description', 'keywords'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description', 'keywords', 'afbeeldingalt'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description', 'keywords', 'afbeeldingalt', 'spijs'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs, leverancier
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description', 'keywords', 'afbeeldingalt', 'spijs', 'leverancier'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs, leverancier, levertijd
, 'id', 'domein', 'naam', 'land', 'streek', 'substreek', 'jaar', 'type', 'smaak', 'formaat', 'druivensoort', 'prijsnormaal', 'prijs6', 'prijs12', 'prijs24', 'info', 'actieid', 'afbeelding', 'kleur', 'titel', 'description', 'keywords', 'afbeeldingalt', 'spijs', 'leverancier', 'levertijd'
levertijdInvalid query: Query was empty
Query []<
, id
, '1'
, id, domein
, '1', 'Bodega Sottano'
, id, domein, naam
, '1', 'Bodega Sottano', 'Sottano Judas Malbec'
, id, domein, naam, land
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië'
, id, domein, naam, land, streek
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza'
, id, domein, naam, land, streek, substreek
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL'
, id, domein, naam, land, streek, substreek, jaar
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007'
, id, domein, naam, land, streek, substreek, jaar, type
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn'
, id, domein, naam, land, streek, substreek, jaar, type, smaak
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'roodvlees, wild, kazen'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs, leverancier
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'roodvlees, wild, kazen', 'LFE'
, id, domein, naam, land, streek, substreek, jaar, type, smaak, formaat, druivensoort, prijsnormaal, prijs6, prijs12, prijs24, info, actieid, afbeelding, kleur, titel, description, keywords, afbeeldingalt, spijs, leverancier, levertijd
, '1', 'Bodega Sottano', 'Sottano Judas Malbec', 'Argentinië', 'Mendoza', 'NULL', '2007', 'droge volle rode gekruide wijn', 'wijn met warme aroma's en veel fruit en mooie kruidigheid', '75', 'NULL', '54,95', '43,95', '43,45', '42,95', 'Diep donkerrode en heldere kleur. Deze bijzondere wijn heeft een intens aroma en complexiteit. Met aroma’s van kersen, maar bovenal de kruidigheid van snuiftabak, cassis, witte peper, kruidnagel, wat chocolade en munt.', 'NULL', '../uploads/sottano judas.jpg', 'Rood', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'Sottano Judas Malbec', 'roodvlees, wild, kazen', 'LFE', 'NULL'
NULLInvalid query: Query was empty
Query []<
, id
, '2'

I have re-examined the result and I noticed the NULL directly before "Invalid Query"
Try to catch null values with

if( !empty($cell->nodeValue) )
    {
        switch( $index)
        {
            case 1:
                //'domein' should be a column name in the database
                $data['domein'] = $cell->nodeValue;
                break;
            case 2: 
                break;
            case    
                ...
            case 26:
                break;
            default
                echo "This wasn't really expected";
        }
    }

I'm getting a bit out of options :-( The quote mention could be replaced by str_replace() but I don't thing that the problem (but I may be wrong).

Somehow appears the line

return "insert into wijnen (" . substr($columns, 2) . ") values (" . substr($values, 2) . ")";

return something like "".

I don't get it right now...

Sorry sorry sorry I advised you badly by the line

mysql_query(mysql_real_escape_string($sql);

This will result in things like VALUES (\'red\', .... and will never work.

Apply the mysql_real_escape_string() to each separate value.

//create the query with the available data
    $columns = "";
    $values = "";
    foreach($data as $key => $value)
    {
        $columns .= ", " . $key;
        echo $columns . "<br/>"; 

        $escVal = mysql_real_escape_string($value);
        if( !$escVal )
        {
            echo 'Invalid escape: ' . mysql_error();
            $values .= ", ''";
        }
        else
        {
            $values .= ", '" . $escVal . "'";
        }
        echo $values . "<br/>";
    }

Please check also the variables with which you call the function doQuery....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.