Jump to content

Parse error: syntax error, unexpected T_ECHO


paulbray

Recommended Posts

Hi I am having problems with this script checked and checked but with no joy can you assist a php newb

 

<?php # Product Entry

$page_title = 'Product Entry';

if (isset($_POST['Submit'])) {

$errors = array();

if (empty($_POST['SKU_ProductID'])) {
	$errors[] = 'Please enter Product ID.';
} else {
	$sid = trim($_POST['SKU_ProductID']);
}

if (empty($_POST['SKU_MerchSKUID'])) {
	$errors[] = 'Please enter Merchant SKU.';
} else {
	$mid = trim($_POST['SKU_MerchSKUID']);
}

if (empty($_POST['Game_Title'])) {
	$errors[] = 'Please enter Game Title.';
} else {
	$gt = trim($_POST['Game_Title']);
}

if (empty($_POST['Platform'])) {
	$errors[] = 'Please enter Platform.';
} else {
	$pl = trim($_POST['Platform']);
}

if (empty($_POST['Genre'])) {
	$errors[] = 'Please enter Genre.';
} else {
	$ge = trim($_POST['Genre']);
}

if (empty($_POST['Weight'])) {
	$errors[] = 'Please enter Weight.';
} else {
	$we = trim($_POST['Weight']);
}

if (empty($_POST['Supplier'])) {
	$errors[] = 'Please enter Supplier.';
} else {
	$sup = trim($_POST['Supplier']);
}

if (empty($_POST['Supplier_Price'])) {
	$errors[] = 'Please enter Supplier Price.';
} else {
	$sp = trim($_POST['Supplier_Price']);
}

if (empty($_POST['Cashback'])) {
	$errors[] = 'Please enter Cashback %.';
} else {
	$cb = trim($_POST['Cashback']);
}

if (empty($_POST['Cashback_Amount'])) {
	$errors[] = 'Please enter Cashback Amount.';
} else {
	$cba = trim($_POST['Cashback_Amount']);
}

if (empty($errors)) {

	require_once ('connect.php');

	$q = "INSERT INTO Products (SKU_ProductID, SKU_MerchSKUID, Game_Title, Platform, Genre, Weight, Supplier, Supplier_Price, Cashback, 					        Cashback_Amount) VALUES ('$sid' , '$mid' , '$gt' , '$pl' , '$ge' , '$we' , '$sup' , '$sp' , '$cb' , '$cba')";

	$r = @mysql_query ($dbc, $q);

	if ($r) {

		echo '<H1>This game has been added to the database.</H1>';
	} else
	{
		echo '<H1>Product Addition Error</H1>
		<p class="error">The game could not be added to the database.</p>';

	echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';

	}

	mysqli_close($dbc);

	exit ();

} else {

	echo '<H1>Error!</H1>
	<p class="error">The Following error(s) occurred:<br />';

	foreach ($errors as $msg {	

		[b]echo " - $msg<br />\n";[/b]		}

	echo '</p><p>Please try again.</p><p><br /></p>';

}

[b]}[/b]
?>

 

The errors regards syntax I see on dreamweaver are in bold.

 

Thanks

 

Paul

I have removed the end closing bracket which dreamweaver was showing had issues but am left with the error on line

 

echo " - $msg<br />\n";

 

for what I can see the closing bracket is in place as i added one after the foreach statement and it kick up another error

Removed? In the code you posted before there wasn't a closing bracket after the foreach expression..?

 

Should be:

 

foreach ($errors as $msg) {

 

Forgive me I have had a blonde moment confuse between { and ( Just figured out,  Thans for your quick reply.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.