Comunidad de diseño web y desarrollo en internet online

que esta mal con este codigo???!!!!

Citar            
MensajeEscrito el 02 Feb 2010 02:40 pm
Se que es simple pero me estoy iniciando en el mundo php, no entiendo por donde esta fallando, please ayuda, a todo esto es un formulario simple para subir info a una base de datos.

Este codigo ademas tiene un script, para que aparesca una ventana cuando un campo no este escrito, si la solucion implica borrarlo, no hay problema.

saludos

Código :

 

<?php
$link = mysql_connect('localhost', xxxx_aaaaa', '123456') or die('Could not connect: ' . mysql_error()); 
$db_selected = mysql_select_db('xxxx_contacto', $link) or die ('Error while connecting to database: ' . mysql_error());

$opt=$HTTP_GET_VARS["opt"];

if ($opt==1)
{
$nombre=$HTTP_GET_VARS["nombre"];
$apellido=$HTTP_GET_VARS["apellido"];
$telefono=$HTTP_GET_VARS["telefono"];

$sql="insert into 'demo2' (nombre,apellido,telefono) values ('".$nombre."' ,'".$apellido."' ,'".$telefono."')";
$res=mysql_query($sql,$bd) or die (msql_error($dbi)."<br>Error.<br>"
}

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulario</title>

</head>


<script language="javascript">

function verifica()
{
if (f.nombre.value="")
{
alert("Por favor ingrese su nombre");
return;
}
f.opt.value="1";
f.enviar();
}
</script>

<body>

<form name="f">
<input type="hidden" name="opt" value="1"/>
<table width="23%" border="0">
  <tr>
    <td width="17%">Nombre</td>
    <td width="83%"><label>
      <input type="text" name="nombre" id="nombre"/>
    </label></td>
  </tr>
  <tr>
    <td>Apellido</td>
    <td><label>
      <input type="text" name="apellido" id="apellido" />
    </label></td>
  </tr>
  <tr>
    <td>Telefono</td>
    <td><label>
      <input type="text" name="telefono" id="telefono" />
    </label></td>
  </tr>
  <tr>
    <td><label>
      <input type="submit" name="enviar" id="enviar" value="Enviar" onclick=verifica()/>
    </label></td>
    <td><label>
      <input name="restablecer" type="reset" id="restablecer" value="Restablecer" />
    </label></td>
  </tr>
</table>
</form>

</body>
</html>

Por SexyMotherFucker

4 de clabLevel



 

msie8
Citar            
MensajeEscrito el 02 Feb 2010 03:31 pm
Deverias ponernos que error te lanza php , el error que encontre a simple vista es:

Código PHP :

$link = mysql_connect('localhost', [b]xxxx_aaaaa'[/b], '123456')

xxxx_aaaaa' te falto la comilla del principio 'xxxx_aaaaa'

Por Xer0s

Claber

276 de clabLevel

3 tutoriales

 

Colombia

chrome
Citar            
MensajeEscrito el 02 Feb 2010 04:00 pm
Además estás usando $HTTP_GET_VARS lo cual está obsoleto. Usa $_GET directamente.

Por DriverOp

Claber

2510 de clabLevel



 

opera
Citar            
MensajeEscrito el 03 Feb 2010 12:36 am
Amigos

revise el codigo, y cambie los detalles que me dijeron, lamentablemente aun no funciona, porfa revisen bien el asunto

saludos!!!!

Por SexyMotherFucker

4 de clabLevel



 

msie8
Citar            
MensajeEscrito el 03 Feb 2010 02:39 am
Relamente , si deseas que te ayudemos...
Que error o que te impide la ejecucion del scriop?
que error , que funcion, que linea , que archivo?

Por Xer0s

Claber

276 de clabLevel

3 tutoriales

 

Colombia

chrome
Citar            
MensajeEscrito el 03 Feb 2010 03:13 am
tienes razon disculpa, el error que me aparec es el siguiente

Parse error: syntax error, unexpected ';' in /home/amaliaje/public_html/formulario2/formulario1.php on line 21

saludos

Por SexyMotherFucker

4 de clabLevel



 

msie8
Citar            
MensajeEscrito el 03 Feb 2010 07:41 am
En la línea que comienza con $res=... te falta un ) y un ; al final de la sentencia.

Por DriverOp

Claber

2510 de clabLevel



 

opera

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.