Jump to content

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


jrodd32

Recommended Posts

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.
Link to comment
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
Link to comment
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]
Link to comment
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.
Link to comment
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.
Link to comment
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]
Link to comment
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:

?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.