Jump to content

Parse Error


jec99448

Recommended Posts

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. 
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.