How can i get the value of a field in sql and give it to a php variable?

My problem is i have to update the value of the field 'alias' on the table usuaris. But i don't know how to get this value and give it to the variable i want so i can update the row later. I have been trying many things and right now the piece of program that don't work is this:

        $cog=$_POST["cognoms"];
    $longCog1="SELECT INSTR(cognoms, ' ') FROM usuaris WHERE cognoms='$cog'";
    $comanda=oci_parse($connexio, $longCog1);
    $exit=oci_execute($comanda);
    if($longCog1<5)
    {
        $ComandaAlias=oci_parse($connexio,"SELECT SUBSTR(nom, 1, 3)||SUBSTR(cognoms, 1, ($longCog1-1))||SUBSTR(cognoms, ($longCog1+1), (5-$longCog1)) FROM usuaris WHERE alias='temporal'");
        oci_execute($ComandaAlias);
        $Alias = oci_fetch_array($ComandaAlias, OCI_ASSOC+OCI_RETURN_NULLS);
    }
    else {
        $ComandaAlias=oci_parse($connexio,"SELECT SUBSTR(nom, 1, 3)||SUBSTR(cognoms, 1, 4) FROM usuaris WHERE alias='temporal'");
        oci_execute($ComandaAlias);
        $Alias = oci_fetch_array($ComandaAlias, OCI_ASSOC+OCI_RETURN_NULLS);
    }
    $sentenciaModifica= "UPDATE usuaris SET alias='$Alias' WHERE alias='temparal'";
    $comanda=oci_parse($connexio, $sentenciaModifica);
    $exit=(oci_execute($comanda));

The error is that i can not update a null value to alias.