/*** connect to the database ***/ $link = @mysql_connect($hostname, $username, $password); /*** check if the link is a valid resource ***/ if(is_resource($link)) { /*** if we are successful ***/ echo 'Connected successfully
'; /*** select the database we wish to use ***/ if(mysql_select_db("ComNet", $link) === TRUE) { /*** sql to INSERT a new record ***/ $sql = "INSERT INTO units (`Name`) VALUES (`$var`)"; /*** run the sql query ***/ if(mysql_query($sql, $link)) { echo 'New record created successfully
'; } else { echo 'Unable to INSERT data:
' . $sql .'
' . mysql_error(); } } /*** if we are unable to select the database show an error ***/ else { echo 'Unable to select database'; } /*** close the connection ***/ mysql_close($link); } else { /*** if we fail to connect ***/ echo 'Unable to connect'; } ?> using http://localhost/addunit.php?unit=g6 respownds with Connected successfully Unable to INSERT data: INSERT INTO units (`Name`) VALUES (`G6`) Unknown column 'G6' in 'field list'