paulbray Posted April 11, 2011 Share Posted April 11, 2011 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 https://forums.phpfreaks.com/topic/233340-parse-error-syntax-error-unexpected-t_echo/ Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 You're missing a closing bracket in your foreach loop: foreach ($errors as $msg { Link to comment https://forums.phpfreaks.com/topic/233340-parse-error-syntax-error-unexpected-t_echo/#findComment-1199944 Share on other sites More sharing options...
paulbray Posted April 11, 2011 Author Share Posted April 11, 2011 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 https://forums.phpfreaks.com/topic/233340-parse-error-syntax-error-unexpected-t_echo/#findComment-1199979 Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 Removed? In the code you posted before there wasn't a closing bracket after the foreach expression..? Should be: foreach ($errors as $msg) { Link to comment https://forums.phpfreaks.com/topic/233340-parse-error-syntax-error-unexpected-t_echo/#findComment-1199980 Share on other sites More sharing options...
paulbray Posted April 11, 2011 Author Share Posted April 11, 2011 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 https://forums.phpfreaks.com/topic/233340-parse-error-syntax-error-unexpected-t_echo/#findComment-1199981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.