I have a HTML form; I want to be able to set it so that if a field is empty, the field in the DB will actually be NULL and not just have the word NULL in the field. I thought that using this code would help, but it just puts the word NULL in the field.
PHP Code:
<?php
            
if (isset($_POST['oc_item'])) { 
            
$oc_item mysql_escape_string($_POST['oc_item']);
            
$oc_itemdesc = (!empty($_POST['oc_itemdesc'])) ? $_POST['oc_itemdesc'] : 'NULL';

           
$sql "INSERT INTO catalog_dev (oc_item,oc_itemdesc)
            VALUES(''
$oc_item','$oc_itemdesc')";
        
        
mysql_query($SQL);
        if (
mysql_query($sql)) {
            echo 
'<strong><em>Your data has been submitted</em></strong><br /><br />';
                } else {
            echo 
'<p>Error adding submitted info: ' mysql_error(). '</p>';
        }
        }
        
?>
HTML Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        
        <table>
        <tr>
            <td>Item Name</td>
            <td><input class="forms" type="text" size="50" maxlength="50" name="oc_item" /></td>
        </tr>
        <tr>
            <td>Item Description</td>
            <td><input class="forms" type="text" size="50" maxlength="50" name="oc_itemdesc" /></td>
        </tr>
</table>

        <p><input type="submit" value="Submit item" /></p>
        </form>
Any suggestions? Thank you,