i have written a small code to store the checkbox values into the db.
But its showing me a parse error . Unable to figure out what it could be .
<?php
$dbc = mysqli_connect('localhost', 'root', '', 'test')
or die('Error connecting to MySQL server.');
if(isset($_POST['language']))
{
$language = $_POST['language'];
$n = count($language);
$i = 0;
echo "$n";
echo "The languages you selected are \r\n" .
"<ul>";
while ($i < $n)
{
echo "<li>{$language[$i]}</li> \r\n";
$i++;
}
$query = "INSERT INTO check (ai,rdbms,os,cd,co) VALUES // err ('$language[$i -1]', '$language[$i - 1]', '$language[$i - 1]', // err '$language[$i - 1]', '$language[$i - 1]' ) "; // err
echo "</ul>";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
}
?>
the error its showing is
Parse error: parse error, expecting `']'' in C:\wamp\www\College Web Project\Check Box (tested).php on line 39
the html code is
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Select the area of expertise ur good at <br>
<input name="language[]" type="checkbox" value="Artificial Intelligence">
Artificial Intelligence<br>
<input name="language[]" type="checkbox" value="DataBase">
DataBase <br>
<input name="language[]" type="checkbox" value="OperatingSystems">
OperatingSystems <br>
<input name="language[]" type="checkbox" value="CompilerDesigns">
CompilerDesigns<br>
<input name="language[]" type="checkbox" value="Computer Organization">
Computer Organization<br>
<input name="send" type="submit" id="send" value="Send!">
</form>
Ps : i have incorporated the html code in the same file as the php.