I am trying to insert a value in the database but when I open up the database the value is not inserted in the table. Now all of the code is correct in terms of no misspelling or anything like that but why isn't it inserting a value in the DB table?
I just have to say that this field is not a primary key field, I am just testing this field which is a non primary key field, will it not insert a value in the db table if the primary key value is not inserted?
Below is the code:
<?php
session_start();
$username="xxx";
$password="xxx";
$database="mobile_app";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql="INSERT INTO Session (Course)
VALUES
('$_POST[course]')";
mysql_close();
if (isset($_POST['course'])) {
$_SESSION['course'] = $_POST['course'];
}
?>