/    Sign up×
Community /Pin to ProfileBookmark

Parse error: parse error, unexpected $end

Hi All

Wondering if you could help me…

I get the following error when using [url]http://www.rhwebdesign.net/portfolio.phps[/url]

[QUOTE]

Parse error: parse error, unexpected $end in pathidonotwanttoreleaseonforums on line 339

[/QUOTE]

Because I am on the line of insanity, can someone please point me in the right direction of the code thats dodgy, or better still, give me some corrected code?

I would love you forever if you did ? hehe

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 24.2006 — Probably due to not closing all of your if and/or while blocks. Try indenting your code to make it visually easier to see where such blocks begin and end. For instance, this section near the beginning looks suspicious (I added the indenting and deleted some unnecessary "?><?php" lines for clarity):
[code=php]
<?php
if(!isset($_POST['Submit'])){
$id = $_GET['edit'];
$sql = "SELECT * FROM portfolio WHERE id='$id'";
$result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
$rows = mysql_num_rows($result);
while ($portfolio = mysql_fetch_array($result)) {
$portfolio_title = $portfolio["title"];
$portfolio_client = $portfolio["client"];
$portfolio_type = $portfolio["type"];
$portfolio_project = $portfolio["project"];
$portfolio_description = $portfolio["description"];
$portfolio_picturename = $portfolio["picturename"];
$portfolio_alt = $portfolio["alt"];
$portfolio_url = $portfolio["url"];
}

if(!isset($_POST['Submit'])){
$id = $_GET['edit'];
$sql = "SELECT * FROM portfolio WHERE id='$id'";
$result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
$rows = mysql_num_rows($result);
while ($portfolio = mysql_fetch_array($result)) {
$portfolio_title = $portfolio["title"];
$portfolio_client = $portfolio["client"];
$portfolio_type = $portfolio["type"];
$portfolio_project = $portfolio["project"];
$portfolio_description = $portfolio["description"];
$portfolio_picturename = $portfolio["picturename"];
$portfolio_alt = $portfolio["alt"];
$portfolio_url = $portfolio["url"];
}

if(!isset($_POST['Submit'])){
$id = $_GET['edit'];
$sql = "SELECT * FROM portfolio WHERE id='$id'";
$result = mysql_query($sql) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$sql");
$rows = mysql_num_rows($result);
while ($portfolio = mysql_fetch_array($result)) {
$portfolio_title = $portfolio["title"];
$portfolio_client = $portfolio["client"];
$portfolio_type = $portfolio["type"];
$portfolio_project = $portfolio["project"];
$portfolio_description = $portfolio["description"];
$portfolio_picturename = $portfolio["picturename"];
$portfolio_alt = $portfolio["alt"];
$portfolio_url = $portfolio["url"];
}

if(!isset($_POST['Submit'])){
$id = $_GET['edit'];
$pg4 = "SELECT * FROM page4 WHERE id='$id'";
$result = mysql_query($pg4) or die ("<b>ERROR: </b>" . mysql_error() . "<b>pg4: </b>$pg4");
$rows = mysql_num_rows($result);
while ($page4 = mysql_fetch_array($result)) {
$page4_title = $page4["title"];
$page4_client = $page4["client"];
$page4_type = $page4["type"];
$page4_project = $page4["project"];
$page4_description = $page4["description"];
$page4_picturename = $page4["picturename"];
$page4_alt = $page4["alt"];
$page4_url = $page4["url"];
}

?>
[/code]

The first 3 if blocks seem to do the same thing, and you don't close them so each is being nested inside of the prior if -- is this really what you intended?
Copy linkTweet thisAlerts:
@LimpBagelAug 24.2006 — I'm also a fan of the opening brace on its own line. It helps me visually block code together.

<i>
</i>while(something)
{
//do stuff
}

vs.
<i>
</i>while(something){
//do stuff
}


Also, if your editor supports paren matching just go through your script and make sure it is matching them to the correct partner. I use that most often when looking for mis-matched parens.
Copy linkTweet thisAlerts:
@The_Little_GuyAug 24.2006 — try adding 3 of these [B]}[/B] after this:
[code=php]
$page4 = "INSERT INTO page4 ( id , title , client , project, type, page4_content, url , author, added ) VALUES('', '" .
$_POST['title'] . "', '" . $_POST['client'] . "', '" . $_POST['project'] . "', '" .
$_POST['type'] . "', '" . $_POST['page4_content'] . "', '" . $_POST['url'] . "', '" .
$_SESSION['firstname'] . " " . $_SESSION['lastname'] . "', NOW())";
$result = mysql_query($page4) or die ("<b>ERROR: </b>" . mysql_error() . "<b>SQL: </b>$page4");
$id = mysql_insert_id();
echo "News Story "" . $_POST['title'] . "" added successfully - return to <a href="news.php" onFocus="this.blur();">the News Admin Area</a> or view <a href="../newsstory.php?story=" . $id . "" onFocus="this.blur();">page here</a>!";
}
}
}[/code]
Copy linkTweet thisAlerts:
@Reli4ntAug 25.2006 — I'm also a fan of the opening brace on its own line. It helps me visually block code together.[/QUOTE]
I am a recent convert to this method as well. It takes a while to get used to but in the end it allows you to more easily spot unclosed loops and control statements
×

Success!

Help @rh91uk 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.6,
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,
)...