-3

I'm doing a script that display a list of checkboxes containing data stored in my database: email_list table.

My script:

<img src="blankface.jpg" width="161" height="350" alt="" style="float:right" />
<img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" />
<p>Please select the email addresses to delete from the email list and click Remove.</p> 

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ">

<?php   
    $dbc= mysqli_connect('localhost', 'root', '', 'elvis_store')
        or die('Error connecting to MySQL server.');

    $query = "SELECT * FROM email_list";
    $result = mysqli_query($dbc, $query)
        or die('Error querying database');

    while($row = mysqli_fetch_array($result)) {
        echo '<input type="checkbox" value="' . $row['id']'" name="todelete[]" />';
        echo $row['firstname'];
        echo $row['lastname'];
        echo $row['email'];
        echo '<br />';
    }
    mysqli_close($dbc);
?>

    <input type="submit" name="submit" value="Remove" />

</form>

While I'm running this script, it display a Parse error:

Parse error: syntax error, unexpected ''" name="todelete[]" />'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\wamp\www\removeemail.php on line 16

I don't get this problem.

Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Johny Nassar
  • 41
  • 11

2 Answers2

0

Add . after $row['id']

echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';
Jayesh Chitroda
  • 4,987
  • 13
  • 18
0

You're missing . in your first echo statement. . must be at the both ends to concatenate the string.

Update your code like this.

echo '<input type="checkbox" value="'. $row['id'].'" name="todelete[]" />';

http://php.net/manual/en/language.operators.string.php

Alok Patel
  • 7,842
  • 5
  • 31
  • 47