For loop doesnt work properly

toro484

New Member
I'm trying to create a script that is reading out een exel file.For every row in the file i want to maken a xml file en that file needs to be uploaded to another server.The script worked fine until i added the 'for loop' to read out multiple rows of the file.It doenst create the xml files.So i thinks the problem is in "for loop" but i cant figure it out. \[code\]<?PHPob_start(); include("auth.inc.php"); error_reporting(E_ALL ^ E_NOTICE);require_once 'bol_files/excel_reader2.php';require_once 'bol_files/functie_empty_folder.php';require_once 'bol_files/functie_strip_timestamp.php';require_once 'bol_files/functie_strip_housenumber.php'; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title><link rel="stylesheet" href="http://stackoverflow.com/questions/12302735/rma.css" type="text/css" /></head><body><?phpinclude("header.php");?> <table cellpadding="6" cellspacing="1" border="0" width="400" align="center"><tr><td bgcolor="#DD0101"><div align="center">2D of 3D afbeelding toevoegen</div></td></tr> <tr><td class="containerborder" align="left"><div class="container"> <blockquote style="width:400px;"><center> <?php if($_SERVER['REQUEST_METHOD']=="POST"){//start if post$allowedExts = array("xls");$extension = end(explode(".", $_FILES["file"]["name"]));if (($_FILES["file"]["type"] == "application/vnd.ms-excel")&& ($_FILES["file"]["size"] < 90000)&& in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0){ echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; }else{ echo "<b>Bestands gegevens</b><br>"; echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />";echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";if (file_exists("upload/" . $_FILES["file"]["name"])) { unlink("upload/" . $_FILES["file"]["name"]); } move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "<br><b>Uuploaden</b><BR>"; echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; //start xls read$filepath = "upload/"; $filename = $_FILES["file"]["name"];$data = http://stackoverflow.com/questions/12302735/new Spreadsheet_Excel_Reader($filepath.$filename);$rowcount = $data->rowcount($sheet_index=0);$rows = $rowcount-3; // min kolom namenecho"<br><br><b>Inlezen</b><br>";echo "Regels gescand".$rows." rijen<br><br>"; echo "<b>Uploaden naar externe server</b><br>";echo "Er zijn ".$rows." geupload naar externe server<br>"; //start foreach rij for ($i=4; $i<=$rows; $i++) { echo "test"; $data = http://stackoverflow.com/questions/12302735/new Spreadsheet_Excel_Reader($filepath.$filename); //data bestelling $bestelnummer = $data->val($i,'A'); $emailadres = $data->val($i,'W'); $betaalwijze = "17"; $verzendwijze= "5"; $telefoonnummer= $data->val($i,'X'); $telnummerbezorging = $data->val($i,'X'); //verzendadres $aanhef_verzending = $data->val($i,'B'); $voornaam_verzending = $data->val($i,'C'); $achternaam_verzending = $data->val($i,'D'); $bedrijfsnaam_verzending = $data->val($i,'E'); $adres_verzending_unclean = $data->val($i,'M'); $adres_verzending = strip_housenumber($adres_verzending_unclean); $huisnummer_verzending = preg_replace ('/[^0-9]/', '', $adres_verzending_unclean); $postcode_verzending = $data->val($i,'G'); $woonplaats_verzending = $data->val($i,'H'); //factuuradres $aanhef_facturatie = $data->val($i,'I'); $voornaam_facturatie = $data->val($i,'J'); $achternaam_facturatie = $data->val($i,'K'); $bedrijfsnaam_facturatie = $data->val($i,'L'); $adres_facturatie_unclean = $data->val($i,'M'); $adres_facturatie = strip_housenumber($adres_facturatie_unclean); $huisnummer_facturatie = preg_replace ('/[^0-9]/', '', $adres_facturatie_unclean); $postcode_facturatie = $data->val($i,'N'); $woonplaats_facturatie = $data->val($i,'O'); //artikelen $EAN = $data->val($i,'P'); $referentie = $data->val($i,'Q'); $producttitel = $data->val($i,'R'); $aantal = $data->val($i,'S'); $besteldatum = strip_timestamp($data->val($i,'U')); // strip tijd van datum, config Y-M-D $prijs = $data->val($i,'T'); $prijs_ex = $prijs / 1.19; $btw = "19"; //btw percentage $totaal_prijs= $prijs * $aantal; $totaal_prijs_ex= $totaal_prijs_ex / 1.19; //get artikel id from db //eind get artikel id from db $con = mysql_connect("DELETED"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("abontenbal_art", $con);$result = mysql_query("SELECT * FROM artikelenWHERE artikelcode='".$referentie."'");while($row = mysql_fetch_array($result)){ $artikelid = $row['artikelid']; }//read xml template en replace tags $text = file_get_contents("bol_files/order_template.xml"); $data = http://stackoverflow.com/questions/12302735/preg_replace('/\{([^}]+)\}/e', '${\'$1\'}' , $text); //safe file.... file_put_contents("order_".$bestelnummer.".xml", $data); $file = "order_".$bestelnummer.".xml"; $dest = fopen("DELETED" . $file, "wb"); $src = http://stackoverflow.com/questions/12302735/file_get_contents($file); fwrite($dest, $src, strlen($src)); fclose($dest);}} } else { echo"Invalid file"; } //eind if post } else { ?> <form action="bol.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /><input type="submit" name="submit" value="http://stackoverflow.com/questions/12302735/Uploaden" /> </form> <?php } ?> </center> <br /> <br /> <p> </blockquote> </div> </td> </tr> </tbody> <tfoot> </tfoot> </table> <?php include("footer.php"); ?> </body> </html> <?PHP ob_end_flush(); ?>\[/code\]
 
Back
Top