FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Parsing Error
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Parsing Error [message #172753] Mon, 28 February 2011 00:34 Go to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In my attempts to modify an existing site I now own, I've tried to
implement ideas I've been getting here...and I have a new problem. In
the following code I get a "Parse error", and I can't determine why or
what to fix. The code below represents the minimum code that produces
the following error:

Parse error: syntax error, unexpected T_STRING, expecting ']'
in /home/content/94/6213994/html/contact.php on line 47

Please advise. TIA

//////////////////// Code for contact.php ///////////////////
<?php
include "include/page_top.php";
?>
<table border="0" style="width:455px">
<tr>
<td>
<div class="page_text">
<h1>Contact Us</h1>
</div>
</td>
</tr>
<tr>
<td class="page_text">
For information regarding event timing or production...etc.:
</td>
</tr>
<tr><td class="spacer">&nbsp;</td></tr>
<tr>
<td align="center" >
<?php
//add form submition code
if(isset($_POST['submit_btn']))
{ // Protect against injection attacks
$contact = urldecode($_POST['email']);
if(eregi("\r",$contact) || eregi("\n",$contact) || eregi
("http://",$contact))
{
exit;
}
$to = "myid(at)gmail(dot)com";
$from = "$email\r\nBCC: results(at)raceplaceevents(dot)com";
$subject = "Race Place Events Website Inquiry";
$body1 = "Below is the info submitted:".
"\n\nName: {$_POST['name']}".
"\nEmail: {$_POST['email']}".
"\nName of Event: {$_POST['event_entered']}".
"\n\nComments: \n{$_POST['add_comments]}";
$eml_result = mail($to, $subject, $from, $body1);
if($eml_result)
{
do_msg("<br>Your info has been submitted.<br><br>");
}
else
{
do_msg("<br>There was a problem.<br>");
}
}
?>
</td>
</tr>
</table>
<?php
include "include/page_bottom.php";
?>
Re: Parsing Error [message #172755 is a reply to message #172753] Mon, 28 February 2011 01:14 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/27/2011 7:34 PM, Mike Copeland wrote:
> <?php
> include "include/page_top.php";
> ?>
> <table border="0" style="width:455px">
> <tr>
> <td>
> <div class="page_text">
> <h1>Contact Us</h1>
> </div>
> </td>
> </tr>
> <tr>
> <td class="page_text">
> For information regarding event timing or production...etc.:
> </td>
> </tr>
> <tr><td class="spacer">&nbsp;</td></tr>
> <tr>
> <td align="center">
> <?php
> //add form submition code
> if(isset($_POST['submit_btn']))
> { // Protect against injection attacks
> $contact = urldecode($_POST['email']);
> if(eregi("\r",$contact) || eregi("\n",$contact) || eregi
> ("http://",$contact))
> {
> exit;
> }
> $to ="myid(at)gmail(dot)com";
> $from = "$email\r\nBCC:results(at)raceplaceevents(dot)com";
> $subject = "Race Place Events Website Inquiry";
> $body1 = "Below is the info submitted:".
> "\n\nName: {$_POST['name']}".
> "\nEmail: {$_POST['email']}".
> "\nName of Event: {$_POST['event_entered']}".
> "\n\nComments: \n{$_POST['add_comments]}";
> $eml_result = mail($to, $subject, $from, $body1);
> if($eml_result)
> {
> do_msg("<br>Your info has been submitted.<br><br>");
> }
> else
> {
> do_msg("<br>There was a problem.<br>");
> }
> }
> ?>
> </td>
> </tr>
> </table>
> <?php
> include "include/page_bottom.php";
> ?>

"\n\nComments: \n{$_POST['add_comments]}";
^

Missing single quote

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing Error [message #172766 is a reply to message #172753] Mon, 28 February 2011 12:02 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <MPG(dot)27d49b7435d8c3de9896ae(at)news(dot)eternal-september(dot)org>, mrc2323(at)cox(dot)net (Mike Copeland) wrote:
> In my attempts to modify an existing site I now own, I've tried to
> implement ideas I've been getting here...and I have a new problem. In
> the following code I get a "Parse error", and I can't determine why or
> what to fix. The code below represents the minimum code that produces
> the following error:
>
> Parse error: syntax error, unexpected T_STRING, expecting ']'
> in /home/content/94/6213994/html/contact.php on line 47
>
> Please advise. TIA

"\n\nComments: \n{$_POST['add_comments]}";
should be
"\n\nComments: \n{$_POST['add_comments']}";
Re: Parsing Error [message #172793 is a reply to message #172753] Wed, 02 March 2011 16:10 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Mike Copeland wrote:

> Parse error: syntax error, unexpected T_STRING, expecting ']'
> in /home/content/94/6213994/html/contact.php on line 47
> […]
> "\n\nComments: \n{$_POST['add_comments]}";
^ ^starts here, never ends
`starts here
> $eml_result = mail($to, $subject, $from, $body1);
> if($eml_result)
> {
> do_msg("<br>Your info has been submitted.<br><br>");
> }
> else
> {
> do_msg("<br>There was a problem.<br>");
> }
> }
^ends here
> ?>

The error message is a bit bogus. The reason is that in the first quoted
code line here the inline array reference subscript was not finished with an
apostrophe. As a result, PHP considers the subscript to not have ended
until it reaches the last closing brace (at line 47), supposedly to end the
inline reference.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: Parsing Error [message #172794 is a reply to message #172793] Wed, 02 March 2011 16:38 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Thomas 'PointedEars' Lahn wrote:
> Mike Copeland wrote:
>
>> Parse error: syntax error, unexpected T_STRING, expecting ']'
>> in /home/content/94/6213994/html/contact.php on line 47
>> […]
>> "\n\nComments: \n{$_POST['add_comments]}";
> ^ ^starts here, never ends
> `starts here
>> $eml_result = mail($to, $subject, $from, $body1);
>> if($eml_result)
>> {
>> do_msg("<br>Your info has been submitted.<br><br>");
>> }
>> else
>> {
>> do_msg("<br>There was a problem.<br>");
>> }
>> }
> ^ends here
>> ?>
>
> The error message is a bit bogus. The reason is that in the first quoted
> code line here the inline array reference subscript was not finished with an
> apostrophe. As a result, PHP considers the subscript to not have ended
> until it reaches the last closing brace (at line 47), supposedly to end the
> inline reference.
>
>

...and is most easily spotted if you use a text editor with some
intelligence (I use geany) that turns the hole page end orange..(its all
a string)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: HTML select field where the OPTION text is of different colors
Next Topic: Dynamic Charting Assistance Requested
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 20:34:29 GMT 2024

Total time taken to generate the page: 0.02145 seconds