I think the answer to this is really easy but I've been awake too long and my minds not working!!
The problem is when the function doesn't return false, how can I use the value it returns? The code below doesn't work.
if( insert_order($_POST)!=false )
{
echo $orderID;
}
function insert_order($order_details)
{
if whatever
return false;
else
return $orderID;
}