Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/06/2012, 15:59
oliverm
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Error al conectar PHP con BBDD

Cita:
Iniciado por webankenovi Ver Mensaje


probaste el codigo tal te lo di??? te tira algun error???
Sí, usé este código:
Código:
<!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>Untitled Document</title>
</head>



<body>

<form action="../../Users/Oliver/Desktop/intentos php/insert.php" method="post">
<b>Formulario de registro de Cliente</b> <br><br>

Primer nombre: <input type="text" name="nombre"><br>
Primer apellido: <input type="text" name="apellido"><br>
RUT: <input type="text" name="rut_c"><br>
Calle y número: <input type="text" name="calle_nro"><br>
Comuna: <input type="text" name="comuna"><br>
Región: <input type="text" name="region"><br>

<input type="submit" value="Registrar">
</form>



<?
if($_POST['nombre'])

$host="localhost";
$username="root";
$password="cocodrilo";
$db="omohr4";

$nombre=$_POST['nombre'];
$apellido=$_POST['apellido'];
$rut_c=$_POST['rut_c'];
$calle_nro=$_POST['calle_nro'];
$comuna=$_POST['comuna'];
$region=$_POST['region'];

mysql_connect($host,$username,$password);
@mysql_select_db($db);
$query="SELECT rut_c, fecha, id_orden_pedido 
	   FROM orden_pedido";
$query2 = "INSERT INTO `empleado` (`rut_c`, `nombre`, `apellido`, `calle_nro`, `comuna`, `region`) VALUES ('$rut_c','$nombre','$apellido','$calle_nro','$comuna','$region')";
$registro=mysql_query($query2);

echo "Historial de ordenes de pedido hechas por clientes:";

$result=mysql_query($query);
 

?>

</body>
</html>
Y denuevo imprime hasta el botón registrar, pero luego salen estas líneas de error

Notice: Undefined index: nombre in C:\xampp\htdocs\aers2.php on line 28

Notice: Undefined index: nombre in C:\xampp\htdocs\aers2.php on line 35

Notice: Undefined index: apellido in C:\xampp\htdocs\aers2.php on line 36

Notice: Undefined index: rut_c in C:\xampp\htdocs\aers2.php on line 37

Notice: Undefined index: calle_nro in C:\xampp\htdocs\aers2.php on line 38

Notice: Undefined index: comuna in C:\xampp\htdocs\aers2.php on line 39

Notice: Undefined index: region in C:\xampp\htdocs\aers2.php on line 40

Notice: Undefined variable: host in C:\xampp\htdocs\aers2.php on line 42

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\aers2.php on line 42
Historial de ordenes de pedido hechas por clientes: