Page 1 of 1

PHP XML Problem

Posted: Sat Oct 04, 2008 7:06 am
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?

Re: PHP XML Problem

Posted: Sat Oct 04, 2008 3:32 pm
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 (")