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.

Seems fine except for the query you are building for your INSERT.
Maybe this will offer some assistance.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=encoding">
<title>Insert title here</title>
</head>
    <body>
<?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++;
   }
   echo "</ul>";
   

   // I made the assumption that if you table has the 5 columns representing 
   // the expertises, that they are expecting flags like "Y" and "N" for Yes / No
   // if something different is expected, modify the following 5 lines appropriately.
   $ai = in_array("Artificial Intelligence", $language)?"Y":"N";
   $rdbms = in_array("DataBase", $language)?"Y":"N";
   $os = in_array("OperatingSystems", $language)?"Y":"N";
   $cd = in_array("CompilerDesigns", $language)?"Y":"N";
   $co = in_array("Computer Organization", $language)?"Y":"N";
      
   // I'm guessing that you have a PK field or something to add to this INSERT
   // I don't see this being very useful on its own.
  $query = "INSERT INTO check (ai,rdbms,os,cd,co) VALUES 
               ( '$ai', '$rdbms', '$os', '$cd', '$co' )";

  // Example query: INSERT INTO check (ai,rdbms,os,cd,co) VALUES ( 'Y', 'Y', 'Y', 'N', 'N' )

$result = mysqli_query($dbc, $query)
    or die('Error querying database.');

mysqli_close($dbc);

}
?>
		<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>
    </body>
</html>

i am getting an error saying

error querying database

all the data types in the db i have set it as varchar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.