Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Problema con la base de Datos MySQL

Estas en el tema de Problema con la base de Datos MySQL en el foro de PHP en Foros del Web. Okey, les comento mi situación. Estoy tratando de realizar un formulario de registro completo para un emprendimiento de ventas y servicios, estoy utilizando una tabla ...
  #1 (permalink)  
Antiguo 28/11/2013, 18:29
Avatar de elsmallville  
Fecha de Ingreso: noviembre-2013
Mensajes: 7
Antigüedad: 10 años, 5 meses
Puntos: 0
Problema con la base de Datos MySQL


Okey, les comento mi situación.
Estoy tratando de realizar un formulario de registro completo para un emprendimiento de ventas y servicios, estoy utilizando una tabla "Asistente de Formulario de Inserción de Registro" del objeto de base de datos que hice en PhpMyAdmin.



Entonces lo que ocurre al seleccionar el sexo ocurre lo siguiente:



Yo no entiendo muy bien porque en la base de dato puse Sexo como un Vatchar de 100.



Yo sé que me falta algo, pero no sé muy bien que es, y es por eso que necesito ayuda, tal vez tenga que seleccionar desde la base de datos al campo Sexo y agregar los 2 valores femenino y masculino, pero la verdad es que no sé nada de base de datos es por eso que necesito su ayuda.
Gracias!



Código PHP:
<?php require_once('Connections/bluegreyconexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
if (
PHP_VERSION 6) {
$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"] == "form1")) {
$insertSQL sprintf("INSERT INTO registro (nombres, apellido, usuario, password, email, sexo, edad, dirección, codpostal, provincia, localidad, telefono, telalternativo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Nombres'], "text"),
GetSQLValueString($_POST['Apellidos'], "text"),
GetSQLValueString($_POST['Usuario'], "text"),
GetSQLValueString($_POST['Contrasea'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Sexo'], "text"),
GetSQLValueString($_POST['Edad'], "text"),
GetSQLValueString($_POST['Direccin'], "text"),
GetSQLValueString($_POST['Cdigo_Postal'], "text"),
GetSQLValueString($_POST['Provincia'], "text"),
GetSQLValueString($_POST['Localidad'], "text"),
GetSQLValueString($_POST['Telfono'], "text"),
GetSQLValueString($_POST['Alt_Telfono'], "text"));

mysql_select_db($database_bluegreyconexion$bluegreyconexion);
$Result1 mysql_query($insertSQL$bluegreyconexion) or die(mysql_error());
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BlueGrey - Formulario de Registro</title>
<style>
body {
background:url(images/fondo-registro.jpg) no-repeat;
background-color:#000;
}
#form1 {
font:"Palatino Linotype", "Book Antiqua", Palatino, serif;
color:#999;
position:relative;
top:165px;
}
#enviar {
font-size:18px;
position:relative;
left:30px;
}

</style>
</head>
<body>

<form action="<?php echo $editFormAction?>" method="post" name="form1" id="form1" onSubmit="return validarPasswd()">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre(s):</td>
<td><input type="text" name="Nombres" value="" size="32" style="background:#CCC; color:#000; border-color:#666" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Apellido(s):</td>
<td><input type="text" name="Apellidos" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Usuario:</td>
<td><input type="text" name="Usuario" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Contraseña:</td>
<td><input type="password" name="Contrasea" id="passwd" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Confirmar Contraseña:</td>
<td><input type="password" name="Contrasea" id="passwd2" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">E-mail:</td>
<td><input type="text" name="Email" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/><br /><br /><br /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sexo:</td>
<td valign="baseline">
<table>
<tr>
<td><input type="radio" name="Sexo" value="Masculino" />
Masculino</td>
</tr>
<tr>
<td><input type="radio" name="Sexo" value="Femenino" />
Femenino</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Edad:</td>
<td><input type="text" name="Edad" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/><br /><br /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Dirección:</td>
<td><input type="text" name="Direccin" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Código Postal:</td>
<td><input type="text" name="Cdigo_Postal" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Provincia:</td>
<td><select name="Provincia" style="background:#CCC; color:#000; border-color:#666">
<option value="Ciudad de Buenos Aires" <?php if (!(strcmp("Ciudad de Buenos Aires"""))) {echo "SELECTED";} ?>>Ciudad de Buenos Aires</option>
<option value="Buenos Aires" <?php if (!(strcmp("Buenos Aires"""))) {echo "SELECTED";} ?>>Buenos Aires</option>
<option value="Catamarca" <?php if (!(strcmp("Catamarca"""))) {echo "SELECTED";} ?>>Catamarca</option>
<option value="Chaco" <?php if (!(strcmp("Chaco"""))) {echo "SELECTED";} ?>>Chaco</option>
<option value="Chubut" <?php if (!(strcmp("Chubut"""))) {echo "SELECTED";} ?>>Chubut</option>
<option value="Córdoba" <?php if (!(strcmp("Córdoba"""))) {echo "SELECTED";} ?>>Córdoba</option>
<option value="Corrientes" <?php if (!(strcmp("Corrientes"""))) {echo "SELECTED";} ?>>Corrientes</option>
<option value="Entre Ríos" <?php if (!(strcmp("Entre Ríos"""))) {echo "SELECTED";} ?>>Entre Ríos</option>
<option value="Formosa" <?php if (!(strcmp("Formosa"""))) {echo "SELECTED";} ?>>Formosa</option>
<option value="Jujuy" <?php if (!(strcmp("Jujuy"""))) {echo "SELECTED";} ?>>Jujuy</option>
<option value="La Pampa" <?php if (!(strcmp("La Pampa"""))) {echo "SELECTED";} ?>>La Pampa</option>
<option value="La Rioja" <?php if (!(strcmp("La Rioja"""))) {echo "SELECTED";} ?>>La Rioja</option>
<option value="Mendoza" <?php if (!(strcmp("Mendoza"""))) {echo "SELECTED";} ?>>Mendoza</option>
<option value="Misiones" <?php if (!(strcmp("Misiones"""))) {echo "SELECTED";} ?>>Misiones</option>
<option value="Neuquén" <?php if (!(strcmp("Neuquén"""))) {echo "SELECTED";} ?>>Neuquén</option>
<option value="Río Negro" <?php if (!(strcmp("Río Negro"""))) {echo "SELECTED";} ?>>Río Negro</option>
<option value="Salta" <?php if (!(strcmp("Salta"""))) {echo "SELECTED";} ?>>Salta</option>
<option value="San Juan" <?php if (!(strcmp("San Juan"""))) {echo "SELECTED";} ?>>San Juan</option>
<option value="San Luis" <?php if (!(strcmp("San Luis"""))) {echo "SELECTED";} ?>>San Luis</option>
<option value="Santa Cruz" <?php if (!(strcmp("Santa Cruz"""))) {echo "SELECTED";} ?>>Santa Cruz</option>
<option value="Santa Fe" <?php if (!(strcmp("Santa Fe"""))) {echo "SELECTED";} ?>>Santa Fe</option>
<option value="Santiago del Estero" <?php if (!(strcmp("Santiago del Estero"""))) {echo "SELECTED";} ?>>Santiago del Estero</option>
<option value="Tierra del Fuego" <?php if (!(strcmp("Tierra del Fuego"""))) {echo "SELECTED";} ?>>Tierra del Fuego</option>
<option value="Tucumán" <?php if (!(strcmp("Tucumán"""))) {echo "SELECTED";} ?>>Tucumán</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Localidad:</td>
<td><input type="text" name="Localidad" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Teléfono:</td>
<td><input type="text" name="Telfono" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Alt. Teléfono:</td>
<td><input type="text" name="Alt_Telfono" value="" size="32" style="background:#CCC; color:#000; border-color:#666"/><br /><br /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Enviar" id="enviar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>

<script type="text/javascript">
function validarPasswd() {
var p1 = document.getElementById("passwd").value;
var p2 = document.getElementById("passwd2").value;

if (p1 != p2) {
alert("Las contraseñas deben de coincidir");
return false;
} else {
return true; 
}
}
</script>
</body>
</html>
  #2 (permalink)  
Antiguo 28/11/2013, 18:44
Avatar de Cuervoo  
Fecha de Ingreso: octubre-2013
Mensajes: 165
Antigüedad: 10 años, 6 meses
Puntos: 43
Respuesta: Problema con la base de Datos MySQL

Hacé que imprima el query que genera y mostranos.

Código PHP:
Ver original
  1. $Result1 = mysql_query($insertSQL, $bluegreyconexion) or die("Query: $insertSQL<br />".mysql_error());
  #3 (permalink)  
Antiguo 28/11/2013, 19:01
Avatar de elsmallville  
Fecha de Ingreso: noviembre-2013
Mensajes: 7
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: Problema con la base de Datos MySQL

Cita:
Iniciado por Cuervoo Ver Mensaje
Hacé que imprima el query que genera y mostranos.

Código PHP:
Ver original
  1. $Result1 = mysql_query($insertSQL, $bluegreyconexion) or die("Query: $insertSQL<br />".mysql_error());
A ver hombre... alguna vez te dije que te amo??
Porque sinceramente el día en que te cruce te voy a besar completamente...
Funciono y estoy muy contento ahora de que pueda terminar este sitio y abrirlo a la fecha que di a la gente...
Muchisima gracias... la verdad de corazón posta... me salvaste, me envío el registro a la base de datos...
  #4 (permalink)  
Antiguo 28/11/2013, 19:18
Avatar de Cuervoo  
Fecha de Ingreso: octubre-2013
Mensajes: 165
Antigüedad: 10 años, 6 meses
Puntos: 43
Respuesta: Problema con la base de Datos MySQL

jajaja, me preocupa que haya funcionado porque solamente tenía que imprimir la consulta para a partir de ahí ver qué estaba mal.

Si te lo imprimió, viste cual era el error y lo arreglaste, joya.

Ahora, si pusiste esa línea y anduvo solo, el problema no se solucionó.
  #5 (permalink)  
Antiguo 28/11/2013, 19:27
Avatar de elsmallville  
Fecha de Ingreso: noviembre-2013
Mensajes: 7
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: Problema con la base de Datos MySQL

Cita:
Iniciado por Cuervoo Ver Mensaje
jajaja, me preocupa que haya funcionado porque solamente tenía que imprimir la consulta para a partir de ahí ver qué estaba mal.

Si te lo imprimió, viste cual era el error y lo arreglaste, joya.

Ahora, si pusiste esa línea y anduvo solo, el problema no se solucionó.
Sinceramente hice lo que vos dijiste... solamente cambié el campo de selección de "sexo" a como un menú como puse en las provincias...
Pero aún así... dejame amarte nene u.u"
  #6 (permalink)  
Antiguo 28/11/2013, 19:29
Avatar de Cuervoo  
Fecha de Ingreso: octubre-2013
Mensajes: 165
Antigüedad: 10 años, 6 meses
Puntos: 43
Respuesta: Problema con la base de Datos MySQL

jaja, perfecto.

Etiquetas: formulario, html, mysql, registro, select, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:30.