/    Sign up×
Community /Pin to ProfileBookmark

[code=php]
//line 110
function get_ntf_headers(){

$rtn=””;

if($_POST[‘your_email’]) $rtn=”Good”; //line 115
else $rtn=”Bad”;

return $rtn;
}
//line 120
[/code]

I’m getting this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in … on line 115

I don’t see why I should be getting this error.

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 07.2007 — [code=php]
//line 110
function get_ntf_headers(){

$rtn="";

if($_POST['your_email'])
$rtn="Good"; //line 116
else
$rtn="Bad";

return $rtn;
}
//line 120
[/code]

try it with new lines, I'm not so sure if the same line works very well without braces.
Copy linkTweet thisAlerts:
@NightShift58Oct 07.2007 — Even better would be the following... shortcuts such as leaving out the "{" do not add quality to your scripts, do not really save typing but DO prevent a lot of bugs. Had you used "{" and "}" in your original script, you could have placed both instructions on the same line (not necessarily a good idea either).
[code=php]
<?php
function get_ntf_headers(){
if ($_POST['your_email']) {
$rtn="Good";
} else {
$rtn="Bad";
}
return $rtn;
}
?>
[/code]

My personal preference would be:
[code=php]
<?php
function get_ntf_headers(){
$rtn="Bad";
IF ($_POST['your_email']) :
$rtn="Good";
ENDIF;
return $rtn;
}
?>
[/code]
Copy linkTweet thisAlerts:
@sitehatcheryauthorOct 08.2007 — I found out what it is, but I don't know why it's happening or how to fix it.

It seems that anywhere I have a post variable. For instance,

$_POST['your_email']

If I change that to $something, the error is not thrown. But everywhere I have

$_POST['something'] the interpreter doesn't like it.

What's going on here?
Copy linkTweet thisAlerts:
@NightShift58Oct 08.2007 — I would have suspected it would be the other way around.

Can you post more code? There's a hidden something somewhere....
Copy linkTweet thisAlerts:
@MrCoderOct 08.2007 — Sounds like you have a missing ' or one to many 's somewhere.
Copy linkTweet thisAlerts:
@NightShift58Oct 08.2007 — If you're trying to do this:
[code=php]
echo "This is your email: $_POST['your_email']";
[/code]

it will not work, while:
[code=php]
echo "This is your email: $_POST[your_email]";
[/code]

will.

Try this, always safe:
[code=php]
echo "This is your email: " . $_POST['your_email'];
[/code]
Copy linkTweet thisAlerts:
@MrCoderOct 08.2007 — Or break out of PHP, the best way ?

[code=php]
<?php
// PHP CODE
?>
This is your email: <?php echo $_POST["your_email"]; ?>
<?php
// MORE PHP CODE
?>
[/code]
Copy linkTweet thisAlerts:
@rootOct 08.2007 — Using $_POST is opening you up to exploits, you need to clean the inputs by stripping out any unwanted data like HTML or embedded php code and putting that cleaned data into an array, that way you will close the possible exploit of a multiple submit.
Copy linkTweet thisAlerts:
@NightShift58Oct 09.2007 — Or break out of PHP, the best way ?[/QUOTE]

GW-BASIC?
Copy linkTweet thisAlerts:
@MrCoderOct 09.2007 — It allows dreamweaver design mode to keep its pants on.
×

Success!

Help @sitehatchery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...