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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.