# Php and xml

**URL:** <https://forum.kirupa.com/t/php-and-xml/165789>\
**Category:** Uncategorized\
**Created:** [October 13, 2005, 9:40pm UTC](https://forum.kirupa.com/t/php-and-xml/165789 "2005-10-13T21:40:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![medc](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@medc](https://forum.kirupa.com/u/medc)\
**Post date:** [October 13, 2005, 9:40pm UTC](https://forum.kirupa.com/t/php-and-xml/165789/1 "2005-10-13T21:40:06Z")

</div>

I used the php code from the PHP and XML tutorial to connect to mysql and generate an xml file. The xml file is output without a problem. My actionsscript starts parsing the xml file (its a 75K xml file) but it doesnt parse the whole file! It parses only about half of it and thats it. The problem isnt the actionscript though.

I open the xml file in my html editor (dreamweaver), resave it and then flash loads the whole thing without a problem.

Im using IIS as my localhost and my webhost is running Apache/Linux.

The same exact problem happens when I generate the xml file from either of the two.

I thought it may have to do with the line breaks or with the fopen() function, but when i tried generating the xml file without tabs ( ) or linebreaks (  
), I still have the problem.

Has this happened to anyone? can you please help?

Thanks.

## Below is the code (is modified from the original to account for table relationships)

\<?php  
$host = “localhost”;  
$user = “root”;  
$pass = “”;  
$database = “DB”;  
$linkID = mysql\_connect($host, $user, $pass) or die(“Could not connect to host.”);  
mysql\_select\_db($database, $linkID) or die(“Could not find database.”);  
$query = “SELECT \* FROM Sections”;  
$resultID = mysql\_query($query, $linkID) or die(“Data not found 1.”);  
$xml\_output = “\<Menu\>”;  
for($x = 0 ; $x \< mysql\_num\_rows($resultID) ; $x++){  
$row = mysql\_fetch\_assoc($resultID);  
$xml\_output .= “\<Secciones\>”;  
$xml\_output .= “\<Sections\>” . $row[‘Sections’] . “\</Sections\>”;  
$xml\_output .= “\<SecID\>” . $row[‘SecID’] . “\</SecID\>”;

$query2 = “SELECT \* FROM Subsections WHERE (((Subsections.SecID)=” . $row[‘SecID’] . “))”;  
$resultID2 = mysql\_query($query2, $linkID) or die(“Data not found 2.”);  
for($y= 0 ; $y \< mysql\_num\_rows($resultID2) ; $y++){  
$subsections\_rows = mysql\_fetch\_assoc($resultID2);  
$xml\_output .= “\<SubSecciones\>”;  
$xml\_output .= “\<SubSec\>” . $subsections\_rows[‘SubSec’] . “\</SubSec\>”;  
$xml\_output .= “\<SecID\>” . $subsections\_rows[‘SecID’] . “\</SecID\>”;  
$xml\_output .= “\<SubSecID\>” . $subsections\_rows[‘SubSecID’] . “\</SubSecID\>”;

$query3 = “SELECT \* FROM Products WHERE (((Products.SubSecID)=” . $subsections\_rows[‘SubSecID’] . “))”;  
$resultID3 = mysql\_query($query3, $linkID) or die(“Data not found 3.”);  
for($z= 0 ; $z \< mysql\_num\_rows($resultID3) ; $z++){  
$products\_rows = mysql\_fetch\_assoc($resultID3);  
$xml\_output .= “\<Productos\>”;  
$xml\_output .= “\<ProdName\>” . $products\_rows[‘ProdName’] . “\</ProdName\>”;  
$xml\_output .= “\<Price\>” . $products\_rows[‘Price’] . “\</Price\>”;  
$xml\_output .= “\<Description\>” . $products\_rows[‘Description’] . “\</Description\>”;  
$xml\_output .= “\<Photo\>” . $products\_rows[‘Photo’] . “\</Photo\>”;  
$xml\_output .= “\<SubSecID\>” . $products\_rows[‘SubSecID’] . “\</SubSecID\>”;  
$xml\_output .= “\<TienePDF\>” . $products\_rows[‘tienepdf’] . “\</TienePDF\>”;  
$xml\_output .= “\</Productos\>”;  
}  
$xml\_output .= “\</SubSecciones\>”;  
}  
$xml\_output .= “\</Secciones\>”;  
}  
$xml\_output .= “\</Menu\>”;  
$myFile = “…/menuphp.xml”;  
$fh = fopen($myFile, ‘wb’) or die(“can’t open file”);  
fwrite($fh, $xml\_output);  
fclose($fh);  
$updateGoTo = “catalogo.php”;  
header(sprintf(“Location: %s”, $updateGoTo));  
?\>
