sonnieboy Posted April 13, 2010 Share Posted April 13, 2010 Greetings super experts: I am a first time visitor; so please have it easy on me. I created an online survey which seems to work well. My next task right now is to display the results of survey submitted. However, I am getting the following error when testing the page: Parse error: syntax error, unexpected '<' in C:\survey_results.php on line 100 Here is the code that I am using. Please, please I am a newbie; just jumping from classic ASP to php. I have bolded the line where the error is coming from. <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="800"> <TR><TD WIDTH="800"> <br> Immediately after this line: $comments=$row[comments]; In classic ASP, your server side code begins with <% and ends with %>. I suspect that's the issue here but not real sure. Thanking you in advance. Please see code. <BODY > <DIV align="left"> <p><br /> <strong>Survey Results.<br /> <br /> <?php $dbhost = 'localhost'; $dbuser = '*****'; $dbpass = '*****'; $dbname = 'OnlineSurvey'; $tableval = 'Survey'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname); @mysql_select_db("$dbname") or die("Error: Unable to select database"); $query="SELECT * FROM ".$tableval." "; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row[answer1]; $answer2=$row[answer2]; $answer3=$row[answer3]; $answer4=$row[answer4]; $answer5=$row[answer5]; $answer6=$row[answer6]; $answer7=$row[answer7]; $answer8=$row[answer8]; $answer9=$row[answer9]; $comments=$row[comments]; [b]<TABLE [/b]CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="800"> <TR><TD WIDTH="800"> <br> <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"> <TR> <TD WIDTH="4"> </TD> <TD > </TD> <TD ><TABLE CELLPADDING="5" CELLSPACING="6" BORDER="0"> echo <<<Print <TR> <TD VALIGN="middle" > <FONT ><b>Respondent's Name:</b>{$fullname$} </FONT></TD> <TR> <TD VALIGN="middle" > <FONT ><b>Respondent's Name:</b>{$gender$} </FONT></TD> <TR> <TD VALIGN="middle" > <FONT > <B>1) Is this your first online training program at the School of Library and Information Sciences?</B><BR> {$answer1$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>2) Overall, how positive were your collaborative learning experiences with<br> the School of Library and Information Sciences?</B><BR> {$answer2$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>3) How easy or difficult has it been for you to communicate<br> your thoughts or opinions to the teacher?</B><BR> <input type="radio" name="q3" value="Very Difficult" />Very Difficult</br> {$answer3$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>4) Rate the technical knowledge of the teacher who worked with you</B><BR> {$answer4$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>5) How Accessible is the teacher</B><BR> {$answer5$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>6) If you have collaborated with a group, how easy or difficult has it been for groups<br> you have worked in to agree on a time to meet?</B><BR> {$answer6$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>7) The School of Library and Information Sciences<br> has provided several materials to support our learning</B><BR> {$answer7$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B> Online learning at the School of Library and Information Sciences has been a great experience</B><BR> {$answer8$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>9) Overall, I will take another online traing at The School of Library<br> and Information Sciences again</B><BR> {$answer9$} </FONT> </TD> <TR> <TD VALIGN="middle" > <FONT > <B>10) What do you like most about the School of Library and Information Sciences?</B><BR> {$comments$}</FONT> </TD> Print; } echo '</TABLE>'; ?> </TD> <TD > </TD> </TR></TABLE> </TD></TR> </TABLE> // </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/ Share on other sites More sharing options...
Jax2 Posted April 13, 2010 Share Posted April 13, 2010 You're trying to parse html while still inside PHP ... if you do not want to echo everything, you'll need to escape PHP first ... then go back into it when you want to use php so ?> <table ....blablbla or else you'll need to echo everything: echo "<table cellpadding='0' cellspacing='0' name='blabla'>"; notice, no " when echoing, just use ' or else you'll need to echo out " like this: \" Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1040673 Share on other sites More sharing options...
teamatomic Posted April 13, 2010 Share Posted April 13, 2010 Looks like you are trying to use a HEREDOC but didnt understand the manual. $html=<<<HTML <all_your_html> {$comments} <more_html> HTML; echo $html; notice that the trailing $ was removed from your var. there are no echos in the heredoc, the vars will be extrapolated. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1040679 Share on other sites More sharing options...
sonnieboy Posted April 13, 2010 Author Share Posted April 13, 2010 Thanks you wonderful people for your prompt and helpful pointers. I tried to use the echo only because it appears to be much simpler for me to understand. But I am getting an error still: Unexpected $end. This is at the last line: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Our Survey Page</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <BODY > <DIV align="left"> <p><br /> <strong>Survey Results.<br /> <br /> <?php $dbhost = 'localhost'; $dbuser = '*******'; $dbpass = '******'; $dbname = 'mySurvey'; $tableval = 'Survey'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname); @mysql_select_db("$dbname") or die("Error: Unable to select database"); $query="SELECT * FROM ".$tableval." "; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row[answer1]; $answer2=$row[answer2]; $answer3=$row[answer3]; $answer4=$row[answer4]; $answer5=$row[answer5]; $answer6=$row[answer6]; $answer7=$row[answer7]; $answer8=$row[answer8]; $answer9=$row[answer9]; $comments=$row[comments]; echo"[b]<TABLE [/b]CELLPADDING='0' CELLSPACING='0' BORDER='0' WIDTH='800'>"; echo" <TR><TD WIDTH='800'>"; echo"<br>"; echo"<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'>"; echo"<TR>"; echo" <TD WIDTH='4'> </TD>"; echo" <TD > </TD>"; echo" <TD ><TABLE CELLPADDING='5' CELLSPACING='6' BORDER='0'>"; echo" <TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT ><b>Respondent's Name:</b>{$fullname} </FONT></TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT ><b>Respondent's Name:</b>{$gender} </FONT></TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>1) Is this your first online training program at the School of Library and Information Sciences?</B><BR>"; {$answer1; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>2) Overall, how positive were your collaborative learning experiences with<br> the School of Library and Information Sciences?</B><BR>"; {$answer2; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>3) How easy or difficult has it been for you to communicate<br> your thoughts or opinions to the teacher?</B><BR>"; echo"<input type='radio' name='q3' value='Very Difficult' />Very Difficult</br>"; {$answer3; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>4) Rate the technical knowledge of the teacher who worked with you</B><BR>"; {$answer4; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>5) How Accessible is the teacher</B><BR>"; {$answer5; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>6) If you have collaborated with a group, how easy or difficult has it been for groups<br> you have worked in to agree on a time to meet?</B><BR>"; {$answer6; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>7) The School of Library and Information Sciences<br> has provided several materials to support our learning</B><BR>"; {$answer7; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B> Online learning at the School of Library and Information Sciences has been a great experience</B><BR>"; {$answer8; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>9) Overall, I will take another online traing at The School of Library<br> and Information Sciences again</B><BR>"; {$answer9; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle' >"; echo"<FONT >"; echo"<B>10) What do you like most about the School of Library and Information Sciences?</B><BR>"; {$comments; echo"</FONT>"; echo"</TD>"; } echo "</TABLE>"; echo" </TD>"; echo" <TD> </TD>"; echo" </TR></TABLE>"; echo" </TD></TR>"; echo" </TABLE>"; echo" </BODY>"; echo"</HTML>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1040708 Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 If you open a curly brace, you have to close it. Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1040712 Share on other sites More sharing options...
sonnieboy Posted April 14, 2010 Author Share Posted April 14, 2010 Ok, I am not getting anymore errors but I don't see any data. Can someone please tell me where else I am screwing this up? Thanks a lot BTW: How do you copy your code fully formatted and wrapped just like it was when you pasted? Anytime I copy a code, it all appear in one line. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Our Survey Page</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <BODY > <DIV align="left"><p><br /> <strong>Survey Results.<br /><br /> <?php $dbhost = '*****'; $dbuser = '******'; $dbpass = '******'; $dbname = 'mySurvey'; $tableval = 'Survey'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname); @mysql_select_db("$dbname") or die("Error: Unable to select database"); $query="SELECT * FROM ".$tableval." "; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row[answer1]; $answer2=$row[answer2]; $answer3=$row[answer3]; $answer4=$row[answer4]; $answer5=$row[answer5]; $answer6=$row[answer6]; $answer7=$row[answer7]; $answer8=$row[answer8]; $answer9=$row[answer9]; $comments=$row[comments]; echo"<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' WIDTH='800'>"; echo"<TR><TD WIDTH='800'>"; echo"<br>"; echo"<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'>"; echo"<TR>"; echo"<TD WIDTH='4'> </TD>"; echo"<TD > </TD>"; echo"<TD ><TABLE CELLPADDING='5' CELLSPACING='6' BORDER='0'>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT ><b>Respondent's Name:</b>{$fullname} </FONT></TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT ><b>Respondent's Sex:</b>{$gender} </FONT></TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>1) Is this your first online training program at the School of Library and Information Sciences?</B><BR> {$answer1}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>2) Overall, how positive were your collaborative learning experiences with<br> the School of Library and Information Sciences?</B><BR>{$answer2}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>3) How easy or difficult has it been for you to communicate<br> your thoughts or opinions to the teacher?</B><BR>{$answer3}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>4) Rate the technical knowledge of the teacher who worked with you</B><BR>{$answer4}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>5) How Accessible is the teacher</B><BR>{$answer5}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>6) If you have collaborated with a group, how easy or difficult has it been for groups<br> you have worked in to agree on a time to meet?</B><BR>{$answer6}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>7) The School of Library and Information Sciences<br> has provided several materials to support our learning</B><BR>{$answer7}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B> Online learning at the School of Library and Information Sciences has been a great experience</B><BR>{$answer8}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>9) Overall, I will take another online traing at The School of Library<br> and Information Sciences again</B><BR>{$answer9}"; echo"</FONT>"; echo"</TD>"; echo"<TR>"; echo"<TD VALIGN='middle'>"; echo"<FONT >"; echo"<B>10) What do you like most about the School of Library and Information Sciences?</B><BR>{$comments}"; echo"</FONT>"; echo"</TD>"; } echo "</TABLE>"; echo"</TD>"; echo"<TD> </TD>"; echo"</TR></TABLE>"; echo"</TD></TR>"; echo"</TABLE>"; echo"</BODY>"; echo"</HTML>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041371 Share on other sites More sharing options...
AdRock Posted April 14, 2010 Share Posted April 14, 2010 $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row[answer1]; $answer2=$row[answer2]; $answer3=$row[answer3]; $answer4=$row[answer4]; $answer5=$row[answer5]; $answer6=$row[answer6]; $answer7=$row[answer7]; $answer8=$row[answer8]; $answer9=$row[answer9]; $comments=$row[comments]; you forgot to add the ' after [ and before ] $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row['answer1']; $answer2=$row['answer2']; $answer3=$row['answer3']; $answer4=$row['answer4']; $answer5=$row['answer5']; $answer6=$row['answer6']; $answer7=$row['answer7']; $answer8=$row['answer8']; $answer9=$row['answer9']; $comments=$row['comments']; Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041375 Share on other sites More sharing options...
jcbones Posted April 14, 2010 Share Posted April 14, 2010 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Our Survey Page</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <BODY > <DIV align="left"><p><br /> <strong>Survey Results.<br /><br /> <?php $dbhost = '*****'; $dbuser = '******'; $dbpass = '******'; $dbname = 'mySurvey'; $tableval = 'Survey'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname); @mysql_select_db("$dbname") or die("Error: Unable to select database"); $query="SELECT * FROM ".$tableval." "; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { $fname=$row[fullname]; $gender=$row[gender]; $answer1=$row[answer1]; $answer2=$row[answer2]; $answer3=$row[answer3]; $answer4=$row[answer4]; $answer5=$row[answer5]; $answer6=$row[answer6]; $answer7=$row[answer7]; $answer8=$row[answer8]; $answer9=$row[answer9]; $comments=$row[comments]; $html = <<<HTML <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="800"> <TR><TD WIDTH="800"> <br> <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"> <TR> <TD WIDTH="4"> </TD> <TD > </TD> <TD ><TABLE CELLPADDING="5" CELLSPACING="6" BORDER="0"> <TR> <TD VALIGN="middle"> <FONT ><b>Respondent"s Name:</b>{$fullname} </FONT></TD> <TR> <TD VALIGN="middle"> <FONT ><b>Respondent"s Sex:</b>{$gender} </FONT></TD> <TR> <TD VALIGN="middle"> <FONT > <B>1) Is this your first online training program at the School of Library and Information Sciences?</B><BR> {$answer1} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>2) Overall, how positive were your collaborative learning experiences with<br> the School of Library and Information Sciences?</B><BR>{$answer2} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>3) How easy or difficult has it been for you to communicate<br> your thoughts or opinions to the teacher?</B><BR>{$answer3} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>4) Rate the technical knowledge of the teacher who worked with you</B><BR>{$answer4} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>5) How Accessible is the teacher</B><BR>{$answer5} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>6) If you have collaborated with a group, how easy or difficult has it been for groups<br> you have worked in to agree on a time to meet?</B><BR>{$answer6} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>7) The School of Library and Information Sciences<br> has provided several materials to support our learning</B><BR>{$answer7} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B> Online learning at the School of Library and Information Sciences has been a great experience</B><BR>{$answer8} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>9) Overall, I will take another online traing at The School of Library<br> and Information Sciences again</B><BR>{$answer9} </FONT> </TD> <TR> <TD VALIGN="middle"> <FONT > <B>10) What do you like most about the School of Library and Information Sciences?</B><BR>{$comments} </FONT> </TD> HTML; echo $html; } echo ' </TABLE> </TD> <TD> </TD> </TR></TABLE> </TD></TR> </TABLE> </BODY> </HTML>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041378 Share on other sites More sharing options...
sonnieboy Posted April 14, 2010 Author Share Posted April 14, 2010 hi JCBones, I love your code. It looks elegant. Problem is I am getting an error: Parse error: syntax error, unexpected $end in This is at the bottom of page. It says line 80. Hi AdRock, Thanks a lot too. I am trying your suggestion now. I still need to know how to copy a code from here and have it appear on my editor as it does here. Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041388 Share on other sites More sharing options...
AdRock Posted April 14, 2010 Share Posted April 14, 2010 The unxepected $end means you're missing a curly brace } somewhere Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041395 Share on other sites More sharing options...
sonnieboy Posted April 14, 2010 Author Share Posted April 14, 2010 With your suggestion AdRock, and the realization that php is case sensitive, it is working fine now. Thanks very much to you JCBones and all those who responded. I thank you all very much. Quote Link to comment https://forums.phpfreaks.com/topic/198339-parse-error-syntax-error-please-help/#findComment-1041403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.