Generating xml dynamically from a database using PHP
up vote
0
down vote
favorite
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
|
show 3 more comments
up vote
0
down vote
favorite
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
1
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
If you comment outheader ("Content-Type:text/xml");
what is displayed?
– Nigel Ren
Nov 22 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 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 at 19:02
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
php mysql xml
asked Nov 22 at 15:08
Abhooshan Bhattarai
618
618
1
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
If you comment outheader ("Content-Type:text/xml");
what is displayed?
– Nigel Ren
Nov 22 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 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 at 19:02
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15
|
show 3 more comments
1
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
If you comment outheader ("Content-Type:text/xml");
what is displayed?
– Nigel Ren
Nov 22 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 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 at 19:02
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15
1
1
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
If you comment out
header ("Content-Type:text/xml");
what is displayed?– Nigel Ren
Nov 22 at 15:15
If you comment out
header ("Content-Type:text/xml");
what is displayed?– Nigel Ren
Nov 22 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 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 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 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 at 19:02
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
dont see ;(semicolon) $_xml = '<?xml version="1.0"?>'
– suresh bambhaniya
Nov 22 at 15:14
If you comment out
header ("Content-Type:text/xml");
what is displayed?– Nigel Ren
Nov 22 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 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 at 19:02
@NigelRen Still facing the same error.
– Abhooshan Bhattarai
Nov 23 at 5:15