Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/09/2007, 12:35
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 17 años, 5 meses
Puntos: 28
Re: ERROR: ingreso a SQL

Código PHP:
<?php require('Connections/mailinglist.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
    
$fecha $_POST['fecha1'] . "-" $_POST['fecha2'] . "-" $_POST['fecha3'];
  
$insertSQL sprintf("INSERT INTO registro (id, nombre, apellido, email, telefono, ciudad, fecha) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['telefono'], "int"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
                       
GetSQLValueString($_POST['fecha'], "date"));

  
mysql_select_db($database_mailinglist$mailinglist);
  
$Result1 mysql_query($insertSQL$mailinglist) or die(mysql_error());

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

mysql_select_db($database_mailinglist$mailinglist);
$query_Recordset1 "SELECT * FROM registro ORDER BY nombre ASC";
$Recordset1 mysql_query($query_Recordset1$mailinglist) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
Código PHP:
<form id="form1" name="form1" method="post" action="">
                            </form>
                            
                              <form action="<?php echo $editFormAction?>" method="post" name="form2" id="form2">
                                <table align="center">
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Nombre:</td>
                                    <td><input type="text" name="nombre" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Apellido:</td>
                                    <td><input type="text" name="apellido" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Email:</td>
                                    <td><input type="text" name="email" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Telefono:</td>
                                    <td><input type="text" name="telefono" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Ciudad:</td>
                                    <td><input type="text" name="ciudad" value="" size="32" /></td>
                                  </tr>
                                  <tr valign="baseline">
                                    <td nowrap="nowrap" align="right">Fecha:</td>
                                    <td><label>

                                     <select name="fecha" id="$_request[fecha];">
                                        <option>2007</option>
                                        <option>2006</option>
                                        <option>2005</option>
                                        <option>2004</option>
                                                                            </select>
                                      <select name="fecha2" id="$_request[fecha2];">
                                      <option>01</option>
                                      <option>02</option>
                                      <option>03</option>
                                      <option>04</option>
                                      </select>
                                      <select name="fecha3" id="$_request[fecha3];">
                                      <option>01</option>
                                      <option>02</option>
                                      <option>03</option>
                                      <option>04</option>
                                      </select>
                                    </label>
y aun no inserta!!!!!