Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/05/2009, 14:51
alejandro_mex
 
Fecha de Ingreso: mayo-2009
Ubicación: Estado de México
Mensajes: 7
Antigüedad: 15 años
Puntos: 0
disculpa tanta ignorancia pero es q me marca error ..

Undefined variable: ip

deje mi codigo de esta manera:

<?php


$sql = "SELECT * FROM catalogo_host WHERE ip='$ip'";
$res = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($res) > 0)
{
// ya existe una fila con el $ip especificado

echo "ya existe";
}
else
{
// NO existe, entonces... INSERT

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formhost")) {
$insertSQL = sprintf("INSERT INTO catalogo_host (id, ip, nombre, usuario, fecha) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['ip'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['fecha'], "date"));

mysql_select_db($database_ws, $ws);
$Result1 = mysql_query($insertSQL, $ws) or die(mysql_error());

$insertGoTo = "catalogos.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
//header(sprintf("Location: %s", $insertGoTo));

header("Location: alerta.php");
}
}

?>

Última edición por GatorV; 11/05/2009 a las 17:43