mysql_num_rows null

Hello guys i'm doing a normal select to db, but the mysql_num_rowsis null and i don't know why, i have 7 rows with the select.

If u detect the problem, tell me.

Really thx.

Here the code:

function get_bd_idusuario($usuario){

  $id_usuario = 0;

  //Coger datos a partir del usuario
  $sql="SELECT u.id_usuario
       FROM bd_tecnicos.usuarios AS u 
       WHERE u.usuario='".mysql_real_escape_string($usuario)."';";
  $query=mysql_query($sql,CONECTAR_BD_TECNICOS);

  //Si existe el usuario -- guardar su id
  if(mysql_num_rows($query)>0) $id_usuario = $row[0];

  return $id_usuario;

}

echo (get_bd_idusuario(test));

Using mysql_free_result($query) will free the memory related to $query. So any functions after this, related to $query won't return any value.

Quoted from the documentation of mysql_free_result :

mysql_free_result() only needs to be called if you are concerned about how much memory is being used for queries that return large result sets. All associated result memory is automatically freed at the end of the script's execution.