Jump to content


Photo

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


  • Please log in to reply
16 replies to this topic

#1 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 13 September 2006 - 03:39 PM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 13 September 2006 - 03:41 PM

You need to escape your quotes within the print statement or use single quotes for the print statement

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


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

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.

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 13 September 2006 - 03:43 PM

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:
<?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">';
?>

**EDIT**
wow... beat to the punch again ;) ... great answer, though, right? lol
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 13 September 2006 - 03:45 PM

that didn't work, I still got the same error


#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 13 September 2006 - 04:54 PM

Post your actuall code here. Not just line 16.

Also which example did you use?

#6 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 13 September 2006 - 05:48 PM

<?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>';
}
?>


#7 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 13 September 2006 - 05:57 PM

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.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#8 Hepp

Hepp
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 13 September 2006 - 06:01 PM

You have all single quotes. Once you use the print or echo function in PHP, you need to use quotes. Like this:

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

You have:

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

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

#9 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 13 September 2006 - 06:15 PM

You have all single quotes. Once you use the print or echo function in PHP, you need to use quotes. Like this:

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

You have:

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

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


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

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

Notice how I used single quotes around the face attribute.

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 September 2006 - 06:18 PM

Can you put your post in code /code please
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 13 September 2006 - 06:20 PM

Don't know why it matters, but I will edit it for him.

#12 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 13 September 2006 - 06:29 PM

Don't know why it matters, but I will edit it for him.


only advantage i can think of is that he may be able to see his own mistakes with the color-coding ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 September 2006 - 06:42 PM

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.

<?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}?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 13 September 2006 - 07:22 PM

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:

?>

#15 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 September 2006 - 07:27 PM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#16 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 13 September 2006 - 07:31 PM

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

#17 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 September 2006 - 07:35 PM

no problam well done mate, please goto your first post and press modify and alter the topic add [solved]

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users