PHP XML Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
onlineUser
Forum Newbie
Posts: 2
Joined: Sat Oct 04, 2008 6:40 am

PHP XML Problem

Post by onlineUser »

This is the code used by my php script to generate XML

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<videos>\n";
while ($line = mysql_fetch_assoc($Recordset1 ) ) {
echo "<video url =".$line['photo2']."/>\n";
}
echo "</videos>\n";

when processed it returns:

<?xml version="1.0" encoding="UTF-8"?>
<videos>
<video url =movie_2.swf/>
<video url =movie_3.swf/>
<video url =fk20.swf/>
</videos>

what is missing here are the quotes (") before movie and after swf

If I escape these quotes (\") then there is a processing error happening:

echo "<video url =\".$line['photo2'].\"/>\n";

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /mnt/sites/mysite.com/web/directory/banner.php on line 43

Has anyone an answer to this puzzle?
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: PHP XML Problem

Post by Ziq »

Maybe it will help you.

Code: Select all

 
//...
echo "<video url =\"".$line['photo2']."\"/>\n";
//...
 
Don't confuse a concatenation operator (.) with the quotes (")
Post Reply