I have tried to modify the PHP in an OSCommerce file, while trying to get my OSCommerce site up. I have apparently created the following Parse error: ....... /create_account_success.php on line 16. I am not a programmer and no very little PHP. Is it acceptable to paste the PHP here and ask how can I restore this to a readable format? This is the entire code. The errored code is the following:
<?php
/*
$Id: create_account_success.php,v 1.9 2002/11/19 01:48:08 dgw_ Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2002 osCommerce

Released under the GNU General Public License
*/

define('NAVBAR_TITLE_1', 'Create an Account');
define('NAVBAR_TITLE_2', 'Success');
define('HEADING_TITLE', 'Your Account Has Been Created!');
define('TEXT_ACCOUNT_CREATED', 'Congratulations! Your new account has been successfully created! Please allow 24 hours for Account Activation. <small><b></b></small> <a href="'. tep_href_link(FILENAME_CONTACT_US) '"></a>.<br><br>A confirmation will be sent to the provided email address. If you have not received it within 24 hours, please <a href="' . tep_href_link(FILENAME_CONTACT_US) . '">contact us </a>.');
?>

Can someone please help me correct, whatever is in error? Thank you.

Dani AI

Generated

A PHP "Parse error" is a strict syntax failure: the parser stopped because the file contains invalid PHP before or at the reported line. In this thread the error on create_account_success.php (line 16) is caused by a missing string concatenation operator. As pointed out, the code attempted to join an HTML string and the result of tep_href_link(...) without the required . operator, which makes the parser see an unexpected token.

A corrected, syntactically valid one-line definition (replace the broken define) is:

define('TEXT_ACCOUNT_CREATED', 'Congratulations! Your new account has been successfully created! Please allow 24 hours for Account Activation. <small><b></b></small> <a href="' . tep_href_link(FILENAME_CONTACT_US) . '"></a>.<br /><br />A confirmation will be sent to the provided email address. If you have not received it within 24 hours, please <a href="' . tep_href_link(FILENAME_CONTACT_US) . '">contact us</a>.');

Quick troubleshooting checklist and best practices:

  • Run a syntax check: php -l create_account_success.php to get a fast local error report.
  • Scan the few lines before the error line for missing . (concatenation), unmatched quotes, missing semicolons or parentheses; PHP often flags the line after the real mistake.
  • Check for invisible characters or a BOM at the start of the file (editors can show/strip BOM).
  • Work on a local/dev copy and use version control or keep backups before editing core files. ’s suggestion to post code with proper code tags is useful: syntax highlighting catches many issues early.
  • For long language strings, consider building the text in parts, using sprintf() or separate concatenations for clarity rather than cramming function calls inside one quoted literal.

This fix aligns with ’s diagnosis and avoids editing core behavior: restore the corrected define, run php -l, and the parse error should disappear.

Recommended Answers

All 8 Replies

You appear to have lost a period (.) after tep_href_link(FILENAME_CONTACT_US)

If you add the period before the '" that will fix the parse error.

<?php
include_once 'config.php';

class Database
{
    const server = SERVER;
    const username = USERNAME;
    const password = PASSWORD;

    function connect()
    {
        return mysql_connect(self::server,self::username,self::password);
    }   

    function insertUserinfo($fname,$lname,$email,$address, $drctory, $contactno, $mname, $gender, $usrdatno)
    {
        $datno = $this->getMaxDatno('userinfo', 'datno');
        $query = "INSERT INTO userinfo(datno, firstname, lastname, email, address, drctory, contactno, middlename, gender, usrdatno)
                    VALUES($datno, '$fname', '$lname', '$email', '$address', '$drctory', '$contactno', '$mname', $gender, $usrdatno)";
        mysql_query($query);
        return mysql_affected_rows();   
    }   

    function insertUsermas($username, $pwd, $role,$usrdatno)
    {
        $datno = $this->getMaxDatno('usermas','datno');
        $query = "INSERT INTO usermas(datno,usrdatno,createdate,editdate,username,pwd,delflag,role)
                    VALUES($datno,$usrdatno,NOW(),NOW(),'$username','$pwd',0,$role)";
        echo $query." ";
        mysql_query($query);
        return mysql_affected_rows();
    }

    function insertFiletbl($usrdatno, $maxsize)
    {
        $datno = $this->getMaxDatno('filetbl','datno');

        $query = "INSERT INTO filetbl(datno,usrdatno,maxsize,usedsize,primaryfile)
                    VALUES($datno,$usrdatno,$maxsize,1,'default.php')";

        mysql_query($query);
        return mysql_affected_rows();
    }

    function getMaxDatno($table,$field)
    {
        $query = "SELECT count(*) as counter from ".$table;

        $result = mysql_query($query);
        $aResult = mysql_fetch_array($result,MYSQL_ASSOC);
        if($aResult['counter']=='0')
        {
            return "1";
        }
        else
        {
            $query = "SELECT max(".$field.") as num from ".$table;
            $result = mysql_query($query);
            $aResult = mysql_fetch_array($result,MYSQL_ASSOC);
            $retvalue = $aResult['num'] + 1;
            return $retvalue;
        }
    }

    function login($userName, $password)
    {
        $crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
        $user = base64_encode($crypttext);
        $pwd =  crypt(trim($password), ENKEY);

        $query = "SELECT count(*) exist from usermas 
                    WHERE username = '".$user."' AND pwd = '".$pwd."'";

        $result = mysql_query($query);
        $aResult = mysql_fetch_array($result,MYSQL_ASSOC);
        //echo $query;
        return $aResult['exist'];
    }

    function getDirectoryFromDB($userName)
    {
        $crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
        $user = base64_encode($crypttext);

        $query = "SELECT userinfo.drctory from usermas
                    INNER JOIN userinfo
                    ON userinfo.usrdatno = usermas.usrdatno
                    WHERE usermas.username = '".$user."'";
        $result = mysql_query($query);
        $aResult = mysql_fetch_array($result,MYSQL_ASSOC);          
        return $aResult['drctory'];
    }

    function editPrimaryFile($userName, $newfile)
    {
        $crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
        $user = base64_encode($crypttext);

        $query = "UPDATE filetbl SET primaryfile = '$newfile'
                    WHERE usrdatno = (SELECT usrdatno FROM usermas where username = '$user')";

        $result = mysql_query($query);

        return mysql_affected_rows();   
    }

    function getPrimaryFile($userName)
    {
        $crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
        $user = base64_encode($crypttext);

        $query = "SELECT primaryfile FROM filetbl
                    WHERE usrdatno = (SELECT usrdatno FROM usermas where username = '$user')";

        $result = mysql_query($query);
        $aResult = mysql_fetch_array($result,MYSQL_ASSOC);          
        return $aResult['primaryfile'];
    }
}
?>

Parse error: syntax error, unexpected T_ENDIF in /home/content/c/h/i/chilee89/html/templates/jxtc_newspro_bonus/index.php on line 87 What exactly does this mean?

<?php
include_once 'config.php';

class Database
{
	const server = SERVER;
	const username = USERNAME;
	const password = PASSWORD;
		
	function connect()
	{
		return mysql_connect(self::server,self::username,self::password);
	}	
	
	function insertUserinfo($fname,$lname,$email,$address, $drctory, $contactno, $mname, $gender, $usrdatno)
	{
		$datno = $this->getMaxDatno('userinfo', 'datno');
		$query = "INSERT INTO userinfo(datno, firstname, lastname, email, address, drctory, contactno, middlename, gender, usrdatno)
					VALUES($datno, '$fname', '$lname', '$email', '$address', '$drctory', '$contactno', '$mname', $gender, $usrdatno)";
		mysql_query($query);
		return mysql_affected_rows();	
	}	
	
	function insertUsermas($username, $pwd, $role,$usrdatno)
	{
		$datno = $this->getMaxDatno('usermas','datno');
		$query = "INSERT INTO usermas(datno,usrdatno,createdate,editdate,username,pwd,delflag,role)
					VALUES($datno,$usrdatno,NOW(),NOW(),'$username','$pwd',0,$role)";
		echo $query." ";
		mysql_query($query);
		return mysql_affected_rows();
	}
	
	function insertFiletbl($usrdatno, $maxsize)
	{
		$datno = $this->getMaxDatno('filetbl','datno');
		
		$query = "INSERT INTO filetbl(datno,usrdatno,maxsize,usedsize,primaryfile)
					VALUES($datno,$usrdatno,$maxsize,1,'default.php')";
		
		mysql_query($query);
		return mysql_affected_rows();
	}

	function getMaxDatno($table,$field)
	{
		$query = "SELECT count(*) as counter from ".$table;
		
		$result = mysql_query($query);
		$aResult = mysql_fetch_array($result,MYSQL_ASSOC);
		if($aResult['counter']=='0')
		{
			return "1";
		}
		else
		{
			$query = "SELECT max(".$field.") as num from ".$table;
			$result = mysql_query($query);
			$aResult = mysql_fetch_array($result,MYSQL_ASSOC);
			$retvalue = $aResult['num'] + 1;
			return $retvalue;
		}
	}
	
	function login($userName, $password)
	{
		$crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
		$user = base64_encode($crypttext);
		$pwd =  crypt(trim($password), ENKEY);
		
		$query = "SELECT count(*) exist from usermas 
					WHERE username = '".$user."' AND pwd = '".$pwd."'";
		
		$result = mysql_query($query);
		$aResult = mysql_fetch_array($result,MYSQL_ASSOC);
		//echo $query;
		return $aResult['exist'];
	}
	
	function getDirectoryFromDB($userName)
	{
		$crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
		$user = base64_encode($crypttext);
		
		$query = "SELECT userinfo.drctory from usermas
					INNER JOIN userinfo
					ON userinfo.usrdatno = usermas.usrdatno
					WHERE usermas.username = '".$user."'";
		$result = mysql_query($query);
		$aResult = mysql_fetch_array($result,MYSQL_ASSOC);			
		return $aResult['drctory'];
	}
	
	function editPrimaryFile($userName, $newfile)
	{
		$crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
		$user = base64_encode($crypttext);
		
		$query = "UPDATE filetbl SET primaryfile = '$newfile'
					WHERE usrdatno = (SELECT usrdatno FROM usermas where username = '$user')";
					
		$result = mysql_query($query);
			
		return mysql_affected_rows();	
	}
	
	function getPrimaryFile($userName)
	{
		$crypttext = mcrypt_ecb(MCRYPT_DES, ENKEY, trim($userName), MCRYPT_ENCRYPT);
		$user = base64_encode($crypttext);
		
		$query = "SELECT primaryfile FROM filetbl
					WHERE usrdatno = (SELECT usrdatno FROM usermas where username = '$user')";
					
		$result = mysql_query($query);
		$aResult = mysql_fetch_array($result,MYSQL_ASSOC);			
		return $aResult['primaryfile'];
	}
}
?>

Never mind, that is still extremely ugly though? Use code tags dude.

Parse error: syntax error, unexpected T_ENDIF in /home/content/c/h/i/chilee89/html/templates/jxtc_newspro_bonus/index.php on line 87 What exactly does this mean?

Which script are you referring to?

<?

$myserver = "localhost";
$user = "drupal";
$pass = "drupal";
$mydb = "pc";


$dbhandle = mssql_connect($myserver, $user, $pass)
or die("couldn't connect to server on $myserver");

$selected = mssql_select_permisnet_new($mydb, $dbhandle)
or die("couldn't open the database $mydb");

$query = "Select * from computer block";

$result = mssql_query($query);
$num_rows = mssql_num_rows($result);
while ($rows = mssql_fetch_array($result)
{
echo"<li>".$row["id"].$row["name"].$row["year"]."</li>";
}
mssql_close($dbhandle);
?>

I am having a problem getting the results of my contact form to go to my gmail account. The below code is what I have between the opening and closing tags of my php processing form. Can someone help please?

/*Subject and Email Variables */

	$emailSubject = 'Registration Form!';
	$pbavirginia = 'pbavirginia@gmail.com';

/*Gathering Data Variables */

	$nameField = $_POST['name'];
	$emailField = $_POST['email'];
	$beatauctionField = $_POST['beatauction'];
	$beatbattleField = $_POST['beatbattle'];
	$bothField = $_POST['both'];
	$message = $_POST['message'];

	$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Beat Auction: $beatauction <br>
Beat Battle: $beatbattle <br>
Both: $both <br>
Message: $message <br>
EOD;

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail{$pbavirginia, $emailSubject, $body, $headers};

/* Results rendered as HTML */

	$theResults = <<<EOD
echo "$theResults";

I am getting a parse error on line 27

I am having a problem getting the results of my contact form to go to my gmail account. The below code is what I have between the opening and closing tags of my php processing form. Can someone help please?

/*Subject and Email Variables */

	$emailSubject = 'Registration Form!';
	$pbavirginia = 'pbavirginia@gmail.com';

/*Gathering Data Variables */

	$nameField = $_POST['name'];
	$emailField = $_POST['email'];
	$beatauctionField = $_POST['beatauction'];
	$beatbattleField = $_POST['beatbattle'];
	$bothField = $_POST['both'];
	$message = $_POST['message'];

	$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Beat Auction: $beatauction <br>
Beat Battle: $beatbattle <br>
Both: $both <br>
Message: $message <br>
EOD;

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail{$pbavirginia, $emailSubject, $body, $headers};

/* Results rendered as HTML */

	$theResults = <<<EOD
echo "$theResults";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.