Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/02/2009, 17:33
martuanez
 
Fecha de Ingreso: julio-2008
Mensajes: 109
Antigüedad: 15 años, 10 meses
Puntos: 0
Problema choto con consulta a mysql

Tengo el siguienta codigo para guardar unas variables que salen de un formulario pero me da probllemas al momento de guardarlas y sinceramente he pasado demasiado tiempo tratando de ver que falla, de seguro es algo demasiado simple, pero mis ojos ya no me lo quieren mostrar...

Codigo php:

Código PHP:
if(substr(strtolower($_SERVER['SERVER_NAME']),0,strlen("macbook")) == "macbook") {
    
$usuario "root";
    
$password "";
} else { 
    
$usuario "root";
    
$password "";
    
$nombredb "xxxxxx_database";
}

$link = @mysql_connect("$host","$usuario","$password"); 
@
mysql_select_db("$nombredb",[$link]) OR die ("Fallo en la conexión"n Host$host<br>n User$usuario<br>n DataBase$nombredb<br>n Error" . mysql_error() . "</font>");

@extract($_GET);
@extract($_POST);
@extract($_FILES);

$muestra= mysql_query (SELECT id FROM votes where id <= 4)

echo $muestra

include("
general.php");

$nombre = $_GET["
field1-t2"];
$mail = $_GET["
field3"];
$edad = $_GET["
field4"];
$sexo = $_GET["
field6"];
$pais = $_GET["
field7"];

mysql_query("
INSERT INTO voter(nombremailsexoedad,total_votespaisVALUES ($nombre$mail$sexo$edad,1$pais)ON DUPLICATE KEY UPDATE total_votes=total_votes+1");
echo $mail. $edad . $sexo . $pais ;
?> 

Codigo del formulario ( las variables tienen esos nombres por razones de validacion, un plugin...)

Código HTML:
<?php require('_drawrating.php'); ?>

<!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>Formulario de prueba</title>
<script type="text/javascript" language="javascript" src="js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="js/rating.js"></script>
<script type="text/javascript" language="javascript" src="scripts/jq.form.js"></script>
<script type="text/javascript" language="javascript" src="jquery-1.3.1.js"></script>
<script type="text/javascript" language="javascript" src="nettuts/tutorial.js"></script>
<script type="text/javascript" language="javascript" src="nettuts/runonload.js"></script>
<link rel="stylesheet" type="text/css" href="css/default.css" />
<link rel="stylesheet" type="text/css" href="css/rating.css" />

<script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
		<script src="scriptaculous/src/effects.js" type="text/javascript"></script>
				<script type="text/javascript" src="validation.js"></script>
		<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
<!--
.asterisco {
	color: #F00;
}
-->
</style>
</head>

<body>
<div id="form_vote">
<form id="test2" method="get" action="conexion.php" >
						<fieldset>
							<legend>Votame!</legend>
							
				    <div class="field-label">
								  <label for="field1-t2"><span class="asterisco">(*)</span>Nombre y apellido</label>
								  :</div>
							 <input name="field1-t2" id="field1-t2" class="required" title="Debes poner tu nombre." />						 
							<div class="field-label">
							  <label for="field3"><span class="asterisco">(*)</span>E-mail</label>
							  :</div>
						  <div class="field-widget"><input name="field3" id="field3" class="required validate-email" title="Debes poner tu E-mail." /></div>
							
                            
								<div class="field-label">
								  <label for="field4"><span class="asterisco">(*)</span>Edad</label>
								  :</div>
							  <div class="field-label"><input name="field4" id="field4" class="required validate-number" title="Debes poner tu edad, solo n&uacute;meros." />								
							</div>
                            <br />
							
							<div class="field-label">
							  <label for="field6"><span class="asterisco">(*)</span>Sexo</label>
							  :</div>
						  <select id="field6" name="field6" class="validate-selection" title="Debes poner una opci&oacute;n.">
									<option value="-1" selected="selected">--Seleccione--</option>
                                                          <option value="1">Masculino</option>
                                                          <option value="2">Femenino</option>
                                                       </select>
							<br />
							<div class="field-label">
							  <label for="field7"><span class="asterisco">(*)</span>País</label>
							  :</div>
                                <select id="field7" name="field7" class="validate-selection" title="No has elegido pa&iacute;s">
								<option value="-1" selected="selected">--Seleccione--</option>
                                                          <option value="1">Masculino</option>
                                                          <option value="2">Femenino</option>
                          </select>
							
                                                     		<?php echo rating_bar('star'); ?>					
						</fieldset>
						<input type="submit" value="Enviar" /> <input type="button" value="Borrar" onclick="valid2.reset(); return false" />
</form>
</div>
</div>
<script type="text/javascript">
						var valid2 = new Validation('test2', {useTitles:true});
					</script>
</body>
</html>
<?php require('conexion.php'); ?>