/    Sign up×
Community /Pin to ProfileBookmark

Parse error: parse error, unexpected T_ECHO in

I got the following error on page:

Parse error: parse error, unexpected T_ECHO in /home2/racingri/public_html/new_ad.php on line 25

Here is the code:

[code=php]<?php
require(‘header.php’);
//If you’re not logged in…
if($user->name == ”)
{
echo ‘Sorry, you must be logged in to post an ad…’;
require(‘footer.php’);
die(”);
}

//If you’re trying to post a new ad
if(isset($_POST[‘NewAd’]))
{
//Create the CAd object, and create the ad
$ad = new CAd($sql);
var_dump($_POST);
var_dump($_FILES);
if($ad->NewAd($user->ID, $_POST[‘title’], ((isset($_POST[‘image_l’]) && $_POST[‘image_l’] != ”) ? $_POST[‘image_l’] : $_FILES[‘image_f’]), $_POST[‘category’], $_POST[‘price’], nl2br($_POST[‘info’]), $_POST[‘location’]))
echo ‘<script language=”JavaScript”>alert(“Success. Your ad has been placed.”);</script>’;
}

echo ‘<input type=”checkbox” name=”premier” value=”permier”>’;
echo ‘<input type=”checkbox” name=”bold” value=”bold”>’;
echo ‘<input type=”checkbox” name=”border” value=”border”>’;
if(isset($_POST[‘premier’]) echo(“this checkbox has been checked!”));
if(isset($_POST[‘bold’]) echo(“this checkbox has been checked!”));
if(isset($_POST[‘border’]) echo(“this checkbox has been checked!”));[/code]

If anyone can help, that would awesome! ? Thanks

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 18.2005 — IF clause does not have opening "{" just before the line 25 echo,
Copy linkTweet thisAlerts:
@LaoauthorMay 18.2005 — Thanks for the reply!! ?

So I insert it like:

[code=php]echo '<input type="checkbox" name="premier" value="permier">';
echo '<input type="checkbox" name="bold" value="bold">';
echo '<input type="checkbox" name="border" value="border">';
{
if(isset($_POST['premier']) echo("this checkbox has been checked!"));
if(isset($_POST['bold']) echo("this checkbox has been checked!"));
if(isset($_POST['border']) echo("this checkbox has been checked!"));
}[/code]


I'm not sure if thats right, I'm still new. ?
Copy linkTweet thisAlerts:
@JerryJrMay 18.2005 — [code=php]
if(isset($_POST['premier'])) echo "this checkbox has been checked!";
if(isset($_POST['bold'])) echo "this checkbox has been checked!";
if(isset($_POST['border'])) echo "this checkbox has been checked!";
[/code]


You were missing a ) closing the IF statement.

** In reply to the post above, you do not need { } with echo statements.
Copy linkTweet thisAlerts:
@bokehMay 18.2005 — No! No! No!

[code=php]
echo '<input type="checkbox" name="premier" value="permier">';
echo '<input type="checkbox" name="bold" value="bold">';
echo '<input type="checkbox" name="border" value="border">';

if(isset($_POST['premier']) {
echo("this checkbox has been checked!"));
}
if(isset($_POST['bold']) {
echo("this checkbox has been checked!"));
}
if(isset($_POST['border']) {
echo("this checkbox has been checked!"));
}
[/code]
Copy linkTweet thisAlerts:
@JerryJrMay 19.2005 — No! No! No!

[code=php]
echo '<input type="checkbox" name="premier" value="permier">';
echo '<input type="checkbox" name="bold" value="bold">';
echo '<input type="checkbox" name="border" value="border">';

if(isset($_POST['premier']) {
echo("this checkbox has been checked!"));
}
if(isset($_POST['bold']) {
echo("this checkbox has been checked!"));
}
if(isset($_POST['border']) {
echo("this checkbox has been checked!"));
}
[/code]
[/QUOTE]


Sorry that does not work for me. You will still need to close the IF statement in order for the isset to be evaluated then do the echo statement. Please note the removal of the paren from the end of the echo statement and the added paren at the end of the if statement as seen below.

=> if(isset($_POST['premier'])[B])[/B] {

The correct code would be:

[code=php]

echo '<input type="checkbox" name="premier" value="permier">';
echo '<input type="checkbox" name="bold" value="bold">';
echo '<input type="checkbox" name="border" value="border">';

if(isset($_POST['premier'])) {
echo("this checkbox has been checked!");
}
if(isset($_POST['bold'])) {
echo("this checkbox has been checked!");
}
if(isset($_POST['border'])) {
echo("this checkbox has been checked!");
}

[/code]


On a second note, the curly braces are not needed with the IF statements since they are one-liners. They are optional.
Copy linkTweet thisAlerts:
@LaoauthorMay 19.2005 — Awesome! Thanks for all your help. It works now! ?


Only problem is, it won't send it to my mail when it was checked... But I'll make another thread for that. ?

Thanks again, you all are awesome! ?
Copy linkTweet thisAlerts:
@SpectreReturnsMay 19.2005 — It's still good practice to do.
Copy linkTweet thisAlerts:
@sccsolutionsFeb 08.2006 — Hello,

New here..

Just done my very 1st bit of php programming and I seem to be getting a parse error such as the one above. However I tried to do what you said but still getting the same error. Heres my code, its a simple mail form handler..

<?php

$Name = $_POST['Name'];

$Email = $_
POST['Email'];

$Query = $_POST['Query'];

$formsent = mail('[email protected]',

"Request From: $Namern

From: $EmailrnBounce-to: [email][email protected][/email]");

if ($formsent) {

echo "<P>We have received your query from the contact us page on our website. A member of staff will contact you shortly.

Thank you, SCC Solutions";

} else (

echo "I'm sorry, there seems to be a problem with your form. Please try again.";

)

?>

Heres what the web-page states

Parse error: parse error, unexpected T_ECHO in /home/sccsol/public_html/contact/contactform.php on line 172

Please help

Much appreciated in advance

Rgds

Aaron
Copy linkTweet thisAlerts:
@NogDogFeb 08.2006 — You have bracketed your else block with parentheses instead of curly brackets.
Copy linkTweet thisAlerts:
@sccsolutionsFeb 08.2006 — Hi,

Yes I change them from ( to { and that worked ok.

However, I am still not happy with the way its working.

If a field is missed out, it doesnt say the I'm sorry bit, and also when I receive the email from the site, it doesnt have the senders email address in the from field.

Any ideas how I can sort that?

Thanks
×

Success!

Help @Lao 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.19,
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,
)...