Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP to create XML file from Mysql data?
    text
    copied!<p>I have a PHP file that will show some products from Mysql database. this works without any issue.</p> <p>But I need to create an XML file from this PHP file in order to be able to load it into flash.</p> <p>I have done the most part and the PHP file creates an XML file on the server and pulls the data (only text format data, i.e. product name, price, details, date added etc etc) and it works perfectly fine BUT, i don't know what to do for the images part!! </p> <p>This is the original PHP file:</p> <pre><code>&lt;?php // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?&gt; &lt;?php // Run a select query to get my letest 6 items // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount &gt; 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '&lt;table width="100%" border="0" cellspacing="0" cellpadding="6"&gt; &lt;tr&gt; &lt;td width="17%" valign="top"&gt;&lt;a href="product.php?id=' . $id . '"&gt;&lt;img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="83%" valign="top"&gt;' . $product_name . '&lt;br /&gt; $' . $price . '&lt;br /&gt; &lt;a href="product.php?id=' . $id . '"&gt;View Product Details&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?&gt; </code></pre> <p>and this is the PHP file that creates the XML file:</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?&gt; &lt;?php header("Content-Type: text/xml"); //set the content type to xml // Initialize the xmlOutput variable $xmlBody = '&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;'; $xmlBody .= "&lt;XML&gt;"; // Run a select query to get my letest 6 items // Connect to the MySQL database include "../config/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount &gt; 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $image = $row["&lt;a href="../product.php?id=' . $id . '"&gt;&lt;img src="../inventory_images/' . $id . '.jpg" alt="' . $product_name . '"/&gt;&lt;/a&gt;"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $xmlBody .= ' &lt;Data&gt; &lt;DataID&gt;' . $id . '&lt;/DataID&gt; &lt;DataTitle&gt;' . $product_name . '&lt;/DataTitle&gt; &lt;DataDate&gt;' . $price . '&lt;/DataDate&gt; &lt;DataImage&gt;' . $image . '&lt;/DataImage&gt; &lt;DataDescr&gt;' . $date_added . '&lt;/DataDescr&gt; &lt;/Data&gt;'; } // End while loop mysql_close(); // close the mysql database connection $xmlBody .= "&lt;/XML&gt;"; echo $xmlBody; // output the gallery data as XML file for flash } ?&gt; &lt;?php echo $dynamicList; ?&gt; </code></pre> <p>as you can see I have placed this line of code: </p> <pre><code>$image = $row["&lt;a href="../product.php?id=' . $id . '"&gt;&lt;img src="../inventory_images/' . $id . '.jpg" alt="' . $product_name . '"/&gt;&lt;/a&gt;"]; </code></pre> <p>in the code above but I am keep getting this error: Parse error: syntax error, unexpected '.' in line 21 and line 21 is the line of code I mentioned above!</p> <p>I would greatly appreciate your help.</p> <p>Thanks </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload