Q:

MySQL insert incorrect integer value for column at row 1

I have to insert in column field unothree either a Null or an Integer value.
Only the integer value inserts but not the null value    
-- Create table
$sqlquery="CREATE TABLE numberone(uno_ID int NOT NULL AUTO_INCREMENT, 
unoone VARCHAR(50) NOT NULL,
unotwo VARCHAR(50) NOT NULL,
unothree MEDIUMINT(8) UNSIGNED,
unofour VARCHAR(10) NOT NULL,
unofive VARCHAR(20) NOT NULL,
PRIMARY KEY(uno_ID ))";

$sqlquery="INSERT INTO numberone(unoone, unotwo, unothree, unofour, unofive)
VALUES ('$one', '$two', '$three', '$four', '$five')";

A:

$three = $three ? "'$three'" : "NULL";
$sqlquery="INSERT INTO numberone(unoone, unotwo, unothree, unofour, unofive)
VALUES ('$one', '$two', $three, '$four', '$five')";

In other words, move the quotes out of the final query so that the value is either quoted or NULL. In fact, since it's an integer, you don't even need the quotes but I figured you wanted a more generic answer.

