error message Unexpected character in input: '\' (ASCII=92)

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
sighta
Forum Newbie
Posts: 1
Joined: Wed Jun 29, 2005 7:04 pm

error message Unexpected character in input: '\' (ASCII=92)

Post by sighta »

im trying to generate a xml document from a mysql database using php
ive used this code before without any problems.
the only difference is that im trying to add data from a second database table as "<comments>"
however, for some reason im getting an error about character input when i try to do this.

here is my exact error message:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in e:\wamp\www\simonweb\trainblogpost.php on line 55

Parse error: syntax error, unexpected T_STRING in e:\wamp\www\simonweb\trainblogpost.php on line 55
here is my code.
line 55 is commented.

Code: Select all

$con = mysql_connect(&quote;localhost&quote;);
mysql_select_db(&quote;simonweb&quote;);
$qpost = mysql_query(&quote;SELECT id, date, time, idea FROM trainblog1 ORDER BY id DESC&quote;);
$xml = &quote;<?xml version=\&quote;1.0\&quote; encoding=\&quote;UTF-8\&quote;?>\n<!-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by simon (simon) -->\n<trainblog>\n&quote;;
$numrows1 = mysql_num_rows($qpost);
if (!($fp = fopen(&quote;trainblog.xml&quote;,&quote;w&quote;)));	
for ($i=0; $i<$numrows1; $i++){
	$row1 = mysql_fetch_array($qpost);
	$xml .= &quote;\t<entry id=\&quote;$row1&#1111;0]\&quote;>\n\t\t<date>$row1&#1111;1]</date>\n\t\t<time>$row1&#1111;2]</time>\n\t\t<idea>$row1&#1111;3]</idea>\n\t\t<comments>\n&quote;;
	$qcomment = mysql_query(&quote;SELECT author, date, time, said FROM trainblog2 WHERE `id` =$row1&#1111;0]);
	$numrows2 = mysql_num_rows($qcomment);
	for ($j=0; $j<$numrows2; $j++){
		$row2 = mysql_fetch_array($qcomment);
		$xml .= &quote;\t\t\t<comment>\n&quote;; //////////////////////THIS IS LINE 55! 
		$xml .= &quote;\t\t\t\t<author>$row2&#1111;0]</author>\n&quote;;
		$xml .= &quote;\t\t\t\t<date>$row2&#1111;1]</date>\n&quote;;
		$xml .= &quote;\t\t\t\t<time>$row2&#1111;2]</time>\n&quote;;
		$xml .= &quote;\t\t\t\t<said>$row2&#1111;3]</said>\n&quote;;
		$xml .= &quote;\t\t\t</comment>\n&quote;;
	}
$xml .= &quote;\t\t</comments>\n\t</entry>&quote;;
}
$xml .= &quote;</trainblog>&quote;;	
fwrite($fp, $xml);
fclose($fp);
mysql_close($con);
?>
any assistance would be appreicated
Post Reply