Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/05/2004, 12:25
sbalestrini
 
Fecha de Ingreso: mayo-2004
Mensajes: 6
Antigüedad: 19 años, 11 meses
Puntos: 0
$selectSQL = sprintf("SELECT * FROM registrados WHERE login = %s", SQLString($_POST["nick"], "text"));

$result = mysql_query($selectSQL);
if (mysql_num_rows($result)) // el usuario ya existe
{
echo 'El usuario ya esta registrado';
mysql_free_result($usuarios2);
}
else // nuevo usuario
el resto idem

tambien te doy esta funcion que uso para converitr string al formato correcto enuna consulta SQL:

function SQLString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

esta funcion la uso siempre y por ende la incluyo en el fichero conectar.php para tenerla disponible.

espero te sirva de algo.
bye!