Unexpected $end (Parse error)

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Knyfe

Thread Starter
Joined
Nov 5, 2011
Messages
2
I apologize if this is in the wrong section of the forum.

I am currently working on adding a CAPTCHA code to a blog script on my website, and I keep running into Parse errors. Usually I can work them out on my own, but I'm fairly new to PHP, and haven't been able to figure this one out.

"Parse error: syntax error, unexpected $end in /home/a2611929/public_html/blognping/profile.php on line 76"

This is the page's script:
PHP:
<?php

define(ROOTPATH,'./');

$title = 'Your Profile';

require_once(ROOTPATH."inc/begin_code.php");
require_once(ROOTPATH."inc/spider.inc.php");
require_once(ROOTPATH."inc/profile.inc.php");

if (isset($_POST['cancelled'])) {
    header('location:index.php');
}

if (isset($_POST['submitted'])) {
    update();
}

if ($_GET['saveOnly'] !=1)
{
    showForm();
}
bye();

function update()
{
    foreach ($_POST as $k => $v) {
        $$k = mysql_escape_string(trim($v));
    }
    
    if (Profile::isProfileSet()) {
        Profile::changeInfo(1, 'blog_id', $blog_id);
        Profile::changeInfo(1, 'blog_username', $blog_username);
        Profile::changeInfo(1, 'blog_password', $blog_password);
        Profile::changeInfo(1, 'blog_url', $blog_url);
        Profile::changeInfo(1, 'blog_name', $blog_name);
        return true;
    }
    
    $db =& new db;
    $sql = "INSERT INTO #_profiles (profileId, blog_id, blog_username, blog_password, blog_url, blog_name) VALUES('1', '$blog_id', '$blog_username', '$blog_password', '$blog_url', '$blog_name')";
    $db->change_db('profiles', $sql);
    return true;
}

function showForm()
{
    $blogId       = Profile::getInfo(1,'blog_id');
    $blogUserName = Profile::getInfo(1,'blog_username');
    $blogPass     = Profile::getInfo(1,'blog_password');
    $blogName     = Profile::getInfo(1,'blog_name'); 
    include_once ROOTPATH . 'html/profile_form.html';
    bye();
}

function bye()
{ 
    require_once ROOTPATH . 'inc/end_code.php';
    die;
}

{
    session_start();
    include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php';
    $securimage = new Securimage();
    if ($securimage->check($_POST['captcha_code']) == false) {
       // the code was incorrect
       // you should handle the error so that the form processor doesn't continue
       // or you can use the following code if there is no validation or you do not know how
    echo "The security code entered was incorrect.<br /><br />";
    cho. "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
    exit;

}

?>
 
Joined
Nov 4, 2011
Messages
787
this would properly be better in web development but its ok... unexpected $end is a php error... i have had this plenty of times basicly you missed a } somewhere in your code and the page is still waiting for it..then it reaches the end... and taada... unexpected $end.. im having trouble finding... THERE!

{
session_start();
include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
echo "The security code entered was incorrect.<br /><br />";
cho. "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
exit;

}
this is missing a } let me show you

(red shows where you opened the first bracket and blue the second)
{
session_start();
include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
echo "The security code entered was incorrect.<br /><br />";
cho. "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
exit;

}
did you notice that there is no blue } that's the issue you need to close the second one this is what i would do(the green is what i changed)
{
session_start();
include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
echo "The security code entered was incorrect.<br /><br />";
cho. "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
exit;
}
}
hope this helps... If you have any problems with you php from here i'd love to help.. sorry it took so long to post this i would have found it in web development faster
 
Joined
Nov 4, 2011
Messages
787
no problem! your lucky that you server supports php errors some just give you a 500 error... and that is the worst, cause you don't know what the problem is... what line its on.. and if your calling on other php pages you don't even know what file caused the error... anyway if you any more problems or questions with php(or any other web coding) you can post here or private msg me I, any many others would be glad to help
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top