I am trying to check for duplicates prior to insert. I am not able to insert into mySQL with the following code. Any help?

    # editout.php
    # Seth Johnson     
    # Assingment 3 
    # ITEC 325 
    # perform update or insertion and then forward back to graform.php 
    # where can do another selection 

<head><title>Assignment 3</title></head>
//header('Refresh: 1; URL=https://php.radford.edu/~sajohnson/gpaform.php'); 
//database connection

if (isset($_POST['submitted'])){


		$radio = $_POST["radio"]; 
        $sem = $_POST["semester"]; 
		$dept= $_POST["dept"];
        $course = $_POST["courseNo"]; 
        $hours = $_POST["semesterHour"];
		$grade = $_POST["grade"]; 
        $im = $_POST["inMajor"];

if ($radio == "ins") 
           echo "<h2>Perform Table Insert</h2>"; 
            $query="select * from $table where 'courseNo'='{$course}'";
			$results = mysql_query($query);
             //$results = mysql_query($SQLcmd, $conn); 

		  echo 'Course No. already exists';
		$SQLcmd = "INSERT INTO $table (semester,dept, 			
		courseNo,semesterHour,grade,inMajor) VALUES 	    	     
	   // if ($results) 
             //   { 
               //   echo "insert exec"; 
               // { 
                 // echo "insert didn't work"; 
				echo "<h2>Perform Record Delete</h2>"; 
                 $sqlcmd = "DELETE FROM $table WHERE courseNo = '$course'"; 
                 $results = mysql_query($sqlcmd,$conn); 
                 if ($results) 
                   {echo "it worked<br />";} 
                   {echo "NO WORK";} 


  <h2>Source Code</h2> 


Why are you checking for >1 on line 37. I would think that you'd want to check for >0. As it is, your insert may fail because there is already one on file.

That makes sense i am not sure why i at >1. But i am still getting an error, could it be with isSet?

post your error please

Thats the thing i am not getting an error when i run my error test but when i try to insert i am getting the HTTP 500 error on the page