Generating xml dynamically from a database using PHP












0















I cannot figure out the error which says



'This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.'



init.php



<?php
$servername = "localhost";
$username = "root";
$password = null;
$databaseName = "test";

$db = mysqli_connect($servername, $username,
$password, $databaseName)

?>


viewWishList.php



<?php                                            
header ("Content-Type:text/xml");
include ("config/init.php");
$query = "SELECT * FROM members";
$result = mysqli_query($connection, $query) or
die ("Error in query: $query. ".mysql_error());

$_xml = '<?xml version="1.0"?>'
$_xml .="<wishList>";

while($row = mysqli_fetch_array($result)) {

$_xml .="<wishlist>";

$_xml .="<wishlistID>".$row['wishlistID']."
</wishlistID>";
$_xml .="<bookName>".$row['bookName']."
</bookName>";
$_xml .="<bookType>".$row['bookType']."
</bookType>";

$_xml .="</wishlist>";

}

$_xml .="</wishList>";

$xmlobj=new SimpleXMLElement($_xml);
print $xmlobj->asXML();
$xmlobj->asXML(wishlist.xml);

?>









share|improve this question


















  • 1





    dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

    – suresh bambhaniya
    Nov 22 '18 at 15:14











  • If you comment out header ("Content-Type:text/xml"); what is displayed?

    – Nigel Ren
    Nov 22 '18 at 15:15











  • Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

    – Abhooshan Bhattarai
    Nov 22 '18 at 16:09













  • Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

    – Nigel Ren
    Nov 22 '18 at 19:02











  • @NigelRen Still facing the same error.

    – Abhooshan Bhattarai
    Nov 23 '18 at 5:15
















0















I cannot figure out the error which says



'This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.'



init.php



<?php
$servername = "localhost";
$username = "root";
$password = null;
$databaseName = "test";

$db = mysqli_connect($servername, $username,
$password, $databaseName)

?>


viewWishList.php



<?php                                            
header ("Content-Type:text/xml");
include ("config/init.php");
$query = "SELECT * FROM members";
$result = mysqli_query($connection, $query) or
die ("Error in query: $query. ".mysql_error());

$_xml = '<?xml version="1.0"?>'
$_xml .="<wishList>";

while($row = mysqli_fetch_array($result)) {

$_xml .="<wishlist>";

$_xml .="<wishlistID>".$row['wishlistID']."
</wishlistID>";
$_xml .="<bookName>".$row['bookName']."
</bookName>";
$_xml .="<bookType>".$row['bookType']."
</bookType>";

$_xml .="</wishlist>";

}

$_xml .="</wishList>";

$xmlobj=new SimpleXMLElement($_xml);
print $xmlobj->asXML();
$xmlobj->asXML(wishlist.xml);

?>









share|improve this question


















  • 1





    dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

    – suresh bambhaniya
    Nov 22 '18 at 15:14











  • If you comment out header ("Content-Type:text/xml"); what is displayed?

    – Nigel Ren
    Nov 22 '18 at 15:15











  • Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

    – Abhooshan Bhattarai
    Nov 22 '18 at 16:09













  • Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

    – Nigel Ren
    Nov 22 '18 at 19:02











  • @NigelRen Still facing the same error.

    – Abhooshan Bhattarai
    Nov 23 '18 at 5:15














0












0








0


0






I cannot figure out the error which says



'This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.'



init.php



<?php
$servername = "localhost";
$username = "root";
$password = null;
$databaseName = "test";

$db = mysqli_connect($servername, $username,
$password, $databaseName)

?>


viewWishList.php



<?php                                            
header ("Content-Type:text/xml");
include ("config/init.php");
$query = "SELECT * FROM members";
$result = mysqli_query($connection, $query) or
die ("Error in query: $query. ".mysql_error());

$_xml = '<?xml version="1.0"?>'
$_xml .="<wishList>";

while($row = mysqli_fetch_array($result)) {

$_xml .="<wishlist>";

$_xml .="<wishlistID>".$row['wishlistID']."
</wishlistID>";
$_xml .="<bookName>".$row['bookName']."
</bookName>";
$_xml .="<bookType>".$row['bookType']."
</bookType>";

$_xml .="</wishlist>";

}

$_xml .="</wishList>";

$xmlobj=new SimpleXMLElement($_xml);
print $xmlobj->asXML();
$xmlobj->asXML(wishlist.xml);

?>









share|improve this question














I cannot figure out the error which says



'This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.'



init.php



<?php
$servername = "localhost";
$username = "root";
$password = null;
$databaseName = "test";

$db = mysqli_connect($servername, $username,
$password, $databaseName)

?>


viewWishList.php



<?php                                            
header ("Content-Type:text/xml");
include ("config/init.php");
$query = "SELECT * FROM members";
$result = mysqli_query($connection, $query) or
die ("Error in query: $query. ".mysql_error());

$_xml = '<?xml version="1.0"?>'
$_xml .="<wishList>";

while($row = mysqli_fetch_array($result)) {

$_xml .="<wishlist>";

$_xml .="<wishlistID>".$row['wishlistID']."
</wishlistID>";
$_xml .="<bookName>".$row['bookName']."
</bookName>";
$_xml .="<bookType>".$row['bookType']."
</bookType>";

$_xml .="</wishlist>";

}

$_xml .="</wishList>";

$xmlobj=new SimpleXMLElement($_xml);
print $xmlobj->asXML();
$xmlobj->asXML(wishlist.xml);

?>






php mysql xml






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 15:08









Abhooshan BhattaraiAbhooshan Bhattarai

9118




9118








  • 1





    dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

    – suresh bambhaniya
    Nov 22 '18 at 15:14











  • If you comment out header ("Content-Type:text/xml"); what is displayed?

    – Nigel Ren
    Nov 22 '18 at 15:15











  • Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

    – Abhooshan Bhattarai
    Nov 22 '18 at 16:09













  • Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

    – Nigel Ren
    Nov 22 '18 at 19:02











  • @NigelRen Still facing the same error.

    – Abhooshan Bhattarai
    Nov 23 '18 at 5:15














  • 1





    dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

    – suresh bambhaniya
    Nov 22 '18 at 15:14











  • If you comment out header ("Content-Type:text/xml"); what is displayed?

    – Nigel Ren
    Nov 22 '18 at 15:15











  • Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

    – Abhooshan Bhattarai
    Nov 22 '18 at 16:09













  • Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

    – Nigel Ren
    Nov 22 '18 at 19:02











  • @NigelRen Still facing the same error.

    – Abhooshan Bhattarai
    Nov 23 '18 at 5:15








1




1





dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

– suresh bambhaniya
Nov 22 '18 at 15:14





dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'

– suresh bambhaniya
Nov 22 '18 at 15:14













If you comment out header ("Content-Type:text/xml"); what is displayed?

– Nigel Ren
Nov 22 '18 at 15:15





If you comment out header ("Content-Type:text/xml"); what is displayed?

– Nigel Ren
Nov 22 '18 at 15:15













Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

– Abhooshan Bhattarai
Nov 22 '18 at 16:09







Notice: Undefined variable: connection in /opt/lampp/htdocs/a/viewWishList.php on line 27 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /opt/lampp/htdocs/a/viewWishList.php on line 27 Fatal error: Uncaught Error: Call to undefined function mysql_error() in /opt/lampp/htdocs/a/viewWishList.php:27 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/a/viewWishList.php on line 27

– Abhooshan Bhattarai
Nov 22 '18 at 16:09















Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

– Nigel Ren
Nov 22 '18 at 19:02





Change the line to $result = mysqli_query($db, $query) or die ("Error in query: $query. ".mysqli_connect_error());

– Nigel Ren
Nov 22 '18 at 19:02













@NigelRen Still facing the same error.

– Abhooshan Bhattarai
Nov 23 '18 at 5:15





@NigelRen Still facing the same error.

– Abhooshan Bhattarai
Nov 23 '18 at 5:15












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433780%2fgenerating-xml-dynamically-from-a-database-using-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433780%2fgenerating-xml-dynamically-from-a-database-using-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy