Jump to content

Archived

This topic is now archived and is closed to further replies.

jrodd32

Parse error: parse error, unexpected T_STRING in line 16 (solved)

Recommended Posts

line 16:
print"<td width="30%" valign="top" align="left" style="padding-left:2" height="32">";

I don't understand why I getting this message

Share this post


Link to post
Share on other sites
You need to escape your quotes within the print statement or use single quotes for the print statement

[b]Escaped quotes[/b]
[code=php:0]print "<td width=\"30%\" valign=\"top\" align=\"left\" style=\"padding-left:2\" height=\"32\">";[/code]


[b]Single Quotes[/b]
[code=php:0]print '<td width="30%" valign="top" align="left" style="padding-left:2" height="32">';[/code]

You cannot use double quotes within double quotes. You will need to escape the double quotes otherwise PHP will think you have ended the string which you havn't.

Share this post


Link to post
Share on other sites
you're not escaping your quotes, so the parser is ending your print statement early. you need to escape the double quotes or use singles instead:
[code]
<?php
// do this:
print "<td width=\"30%\" valign=\"top\" align=\"left\" style=\"padding-left:2\" height=\"32\">";

// or this:
print '<td width="30%" valign="top" align="left" style="padding-left:2" height="32">';
?>
[/code]

[b]**EDIT**[/b]
wow... beat to the punch again ;) ... great answer, though, right? lol

Share this post


Link to post
Share on other sites
Post your actuall code here. Not just line 16.

Also which example did you use?

Share this post


Link to post
Share on other sites
[code]<?php
function printpage($type,$email,$coach,$coachtype);
{
  print'<HTML>';
  print'<HEAD>';
  print'<FONT FACE='Arial'>';
  print'<Basefont size=2>';
  print'<META NAME='Kentucky High School Athletic Association (KHSAA)'CONTENT='Sports High School KHSAA Kentucky High School Athletic Association'>';
  echo"<TITLE>KHSAA Current List of $coachtype Coaches</TITLE>';
  print'</HEAD>';
  print'<BODY>';
  print'<Body Background=' ' BGColor=#FFFFFF Text=#000000 Link=#0000FF VLink=#800080 ALink=#FF0000>';
  print'<p><br>';
  print'</p><table border='0' cellpadding='0' cellspacing='0' width='60%' bgcolor='#FFFFFF'>';
  print'<tr>';
  print'<td width='50%' align='center'>';
  print'<p align='center'>';
  print'<a href='http://www.khsaa.org/'>';
  print'<img src='http://www.khsaa.org/images/khslogo2.gif' border='0'></a></td>';
  print'<td width='50%' align='center'>';
  print'<p align='center'>';
  print'<a href='http://www.khsaa.org/FTR/banners/clickthru_img.php3'>';
  print'<img src='http://www.khsaa.org//FTR/banners/banner_img.php3' border='0'></a></td>';
  print'</tr>';
  print'</table>';
  print'<outpad,'<br>';
  echo"<br><b>KHSAA Current Master List of $coachtype as of ';
    print date('l F jS Y h:i A');
  print'</b>';
  print'<BR>';
  print'<FONT FACE='Courier'>';
  print'<Basefont size=2></p>';
  print'<PRE>';
  printf("%-25s ","Head Coach");
        printf("%-30s ","School");
        printf("%-20s ","City");
        printf("%-20s ","Phone Number");
        printf("%-20s ","Fax Number");
        printf("%-50s <br><hr>","Coach E-mail");
  while($coaches=mysql_fetch_array($coachlist))
    {
      printf("%-25s ",$coaches[$coach]);
      printf("%-30s ",$coaches[school]);
      printf("%-20s ",$coaches[city]);
      printf("%-20s ",$coaches[phone]);
      printf("%-20s ",$coaches[faxphone]);
      printf("%-50s ",$coaches[$email]);
      print("<br>");
    }
    print("<hr>");
    echo 'Copyright &copy; 2001-2006 Kentucky High School Athletic Association (KHSAA), all rights reservered<br>
    This page is for the exclusive use of the KHSAA. Other use is strictly prohibited. Usage is monitored</font>';
  print'</PRE>';
  print'</html>';
}
?>
[/code]

Share this post


Link to post
Share on other sites
notice on your bolded line that you start the echo statement with double quotes, but you end it with single quotes. you've got to stay consistant when you open and close strings.

Share this post


Link to post
Share on other sites
You have all single quotes. Once you use the print or echo function in PHP, you need to use quotes. Like this:

[color=green]echo("<font face=\"Verdana\">OMG THIS IS SO COOL!</font>");[/color]

You have:

[color=red]echo('<font face='Verdana'>OMG THIS IS SO COOL!</font>');[/color]

You can't do that. That's why you're getting that error.

Share this post


Link to post
Share on other sites
[quote author=Hepp link=topic=107918.msg433635#msg433635 date=1158170470]
You have all single quotes. Once you use the print or echo function in PHP, you need to use quotes. Like this:

[color=green]echo("<font face=\"Verdana\">OMG THIS IS SO COOL!</font>");[/color]

You have:

[color=red]echo('<font face='Verdana'>OMG THIS IS SO COOL!</font>');[/color]

You can't do that. That's why you're getting that error.
[/quote]

Or if you don't want to escape strings this will work as well:

[color=green]echo("<font face='Verdana'>OMG THIS IS SO COOL!</font>");[/color]

Notice how I used single quotes around the face attribute.

Share this post


Link to post
Share on other sites
[quote author=steelmanronald06 link=topic=107918.msg433657#msg433657 date=1158171623]
Don't know why it matters, but I will edit it for him.
[/quote]

only advantage i can think of is that he may be able to see his own mistakes with the color-coding ;)

Share this post


Link to post
Share on other sites
tell me how this comes out please cheers.

might ask your self why did redarrow use html and then use php and php in html well the truth is that when you get your site submitted to search engines your have more chance of a good ranking using html without the print statement.

meny other users might argue that point but that why my websites and clients websites are on the first page of google msn and yahoo and stay there for time.

good luck.

[code]
<?php
function printpage($type,$email,$coach,$coachtype){
?>
 <HTML>
 <HEAD>
 <FONT FACE="Arial">
 <Basefont size="2">
 <META NAME="Kentucky High School Athletic Association (KHSAA)"CONTENT="Sports High School KHSAA Kentucky High School

Athletic Association">
 <TITLE>KHSAA Current List of <?php echo $coachtype; ?> Coaches</TITLE>
 </HEAD>
 <BODY>
 <Body Background=" " BGColor=#FFFFFF Text=#000000 Link=#0000FF VLink=#800080 ALink=#FF0000>
 <p><br>
 </p><table border="0" cellpadding="0" cellspacing="0" width="60%" bgcolor="#FFFFFF">
 <tr>
 <td width="50%" align="center">
 <p align="center">
 <a href="http://www.khsaa.org/">
 <img src="http://www.khsaa.org/images/khslogo2.gif" border="0"></a></td>
 <td width="50%" align="center">';
 <p align="center">
 <a href="http://www.khsaa.org/FTR/banners/clickthru_img.php3">
 <img src="http://www.khsaa.org//FTR/banners/banner_img.php3" border="0"></a></td>
 </tr>
 </table>
 outpad,<br>
 <br><b>KHSAA Current Master List of <?php echo $coachtype; ?> as of
   <?php echo date('l F jS Y h:i A'); ?>
 </b>
 <BR>
 <FONT FACE="Courier">
 <Basefont size=2></p>


<?php
print"<PRE>";
 printf("%-25s ","Head Coach");
       printf("%-30s ","School");
       printf("%-20s ","City");
       printf("%-20s ","Phone Number");
       printf("%-20s ","Fax Number");
       printf("%-50s <br><hr>","Coach E-mail");
 while($coaches=mysql_fetch_array($coachlist))
   {
     printf("%-25s ",$coaches[$coach]);
     printf("%-30s ",$coaches[school]);
     printf("%-20s ",$coaches[city]);
     printf("%-20s ",$coaches[phone]);
     printf("%-20s ",$coaches[faxphone]);
     printf("%-50s ",$coaches[$email]);
     print("<br>");
   }
?>
<div align="center">
<hr>
   Copyright &copy; 2001-2006 Kentucky High School Athletic Association (KHSAA), all rights reservered<br>
   This page is for the exclusive use of the KHSAA. Other use is strictly prohibited. Usage is monitored</font></div>
 </PRE>
 </html>

<?php}?>
[/code]

Share this post


Link to post
Share on other sites
It will display the list now but this error:

Parse error: parse error, unexpected $ in /home/httpd/vhosts/khsaa.org/subdomains/admin/httpdocs/jerrod/tool_kit.inc on line 170

now shows.  I have checked my brackets and <php ?> tags and unless I missed something they line up.

The error is weird because it is the last line in my file and the only code on it is:

?>

Share this post


Link to post
Share on other sites
your missing a } bracket trust me i ment a brace lol lol.

did my way work i got it to work here?

i am still in stiches lol about the bracket.

Share this post


Link to post
Share on other sites
I think i used your way to make it work.  I fixed the other problem.  Thanks for the help, you and everyone else

Share this post


Link to post
Share on other sites
no problam well done mate, please goto your first post and press modify and alter the topic add [solved]

good luck.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.