Naturel Deluxe Posted May 21, 2018 Share Posted May 21, 2018 Hello, I was wondering who could send me in the right direction. I have a sql query that runs out the output I will... That works perfectly... Now I want to use the sql query in a php script to give a xml output everytime I trigger the php. This is the code i have now, but it runs out on a 500 error (I believe the error is created in line 24 - 25) <?php // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT psc5_product.id_product AS 'product_id', psc5_product.ean13 AS 'ean13', psc5_product.price AS 'price', psc5_product.reference AS 'product_reference', psc5_stock_available.quantity AS 'available_stock', psc5_manufacturer.name AS 'brand', psc5_product_lang.description AS 'description', psc5_product_lang.name AS 'title', concat("https://www.natureldeluxe.be/", psc5_category_lang.link_rewrite, "/", psc5_product_lang.link_rewrite) AS 'deeplink', concat("https://www.natureldeluxe.be/", psc5_image.id_image, "-large_default/", psc5_product_lang.link_rewrite, ".jpg") AS 'imagelink' FROM psc5_product INNER JOIN psc5_stock_available ON psc5_stock_available.id_product = psc5_product.id_product INNER JOIN psc5_manufacturer ON psc5_manufacturer.id_manufacturer = psc5_product.id_manufacturer INNER JOIN psc5_product_lang ON psc5_product_lang.id_product = psc5_product.id_product INNER JOIN psc5_category_lang ON psc5_category_lang.id_category = psc5_product.id_category_default INNER JOIN psc5_image ON psc5_image.id_product = psc5_product.id_product" $result = $adb->query($sql); $xml .= "<products>"; while($row=$adb->fetch_array($result)) { $xml .= "<product_id>".$row['fname']."</product_id>"; $xml .= "<ean13>".$row['lname']."</ean13>"; $xml .= "<price>".$row['lname']."</price>"; $xml .= "<product_reference>".$row['lname']."</product_reference>"; $xml .= "<available_stock>".$row['lname']."</available_stock>"; $xml .= "<brand>".$row['lname']."</brand>"; $xml .= "<description>".$row['lname']."</description>"; $xml .= "<title>".$row['lname']."</title>"; xml .= "<deeplink>".$row['lname']."</deeplink>"; xml .= "<imagelink>".$row['lname']."</imagelink>"; } $xml .= "</products>"; $sxe = new SimpleXMLElement($xml); $sxe->asXML("test.xml"); ?> Thanks in advance for your help! Link to comment Share on other sites More sharing options...
jgamio Posted May 22, 2018 Share Posted May 22, 2018 Delete the point to your first $xml $xml .= "<products>"; $xml = "<products>"; Link to comment Share on other sites More sharing options...
mycloudcms Posted October 26, 2018 Share Posted October 26, 2018 Hi, regarding this topic, I am using it for 1.7 version and need to get the category path or just the parent category name! Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now