jec99448 Posted December 5, 2017 Share Posted December 5, 2017 I am new to php and cannot get rid of this error: Parse error: syntax error, unexpected '}', expecting end of file in C:\inetpub\wwwroot\354\Groups\Group-A2\getMarketing.php on line 29 Here is the Query: <?php $content = ""; if (isset($_POST['submit'])) { require_once("db.php"); $customer = mysqli_real_escape_string($con, $_POST['customer']); $content .= " <h4>Marketing Campaign '{$customer}':</h4>"; $query = "SELECT m.tool, m.number_recruited FROM 354groupa2.marketing m"; $results = mysqli_query($con, $query) or die("Query failed: " . mysqli_error($con)); $content .= " <table> <tr> <th>Campagin Tool</th> <th>Number Recruited</th> </tr>"; $content .= " while ($row = mysqli_fetch_array($results)) { <tr> <td>{$row['tool']}</td> <td>{$row['number_recruited']}</td> </tr> </table>"; } mysqli_free_result($results); mysqli_close($con); } ?> Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 5, 2017 Share Posted December 5, 2017 (edited) You are putting the while loop in a string which you do nothing with which is throwing off your brackets matching. You have Php all entwined with HTML. Learn about Separation of Concerns. You need to check the REQUEST METHOD, not hope the name of a button is submitted in order for the script to work. Do not output internal system errors to the user. That info is only good to hackers. You do not need to manually close the connection. Php will do it automatically. I recommend you use PDO. https://phpdelusions.net/pdo Edited December 5, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.