
28/10/2012, 23:48
|
| | Fecha de Ingreso: abril-2011
Mensajes: 18
Antigüedad: 13 años, 10 meses Puntos: 0 | |
Respuesta: No puedo conectar php con mysql Ya si claro tenias cuasatar ahora estoy con mysqli y tengo un error que me sale espero me puedan ayudar.
aquí dejo el formulario que se envía por método POST: EN EL CUAL NO ME ARROJA PROBLEMAS.
<html>
<head>
<title>Registro</title>
</head>
<body>
<form action="formclie.php" method="post">
<table width="400">
<tr>
<td width="150"><label>Nombre:</label></td>
<td width="250"><input type="text" name="nombre" /></td>
</tr>
<tr>
<td><label>Apellido:</label></td>
<td><input type="text" name="apellido" /></td>
</tr>
<tr>
<td><label>Rut:</label></td>
<td><input type="text" name="rut"/></td>
</tr>
<tr>
<td><label>Teléfono:</label></td>
<td><input type="text" name="telefono"/></td>
</tr>
<tr>
<td><label>Celular:</label></td>
<td><input type="text" name="celular"/></td>
</tr>
<tr>
<td><label>Direción:</label></td>
<td><input type="text" name="direccion"/></td>
</tr>
<tr>
<td><label>Comuna:</label></td>
<td><input type="text" name="comuna"/></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="registrarse" value="Registrarse"/></td>
</tr>
</table>
</form>
</body>
</html>
Y AQUÍ EL CODIGO PHP:
<?php
$mysqli = new mysqli('localhost','root','','libreta');
if(mysqli_connect_errno()){
printf("Imposible conectarse: %s\n", mysqli_connect_error());
exit();
}
$query = "insert into cliente (nombre,apellido,rut,telefono,celular,direccion,co muna) values(?,?,?,?,?,?,?)";
if($stmt = mysqli->prepare($query)){
$stmt->bind_param('sssssss', $_post['nombre'],
$_post['apellido'],
$_post['rut'],
$_post['telefono'],
$_post['celular'],
$_post['direccion'],
$_post['comuna']);
$stmt->execute();
$stmt->close();
}
?>
<html>
<head>
<title>Registrarse</title>
</head>
<body>
<h1><?=$_POST['nombre'];?>, usted se ha registrado exitosamente</h1>
</body>
</html>
EL CUAL DEBO AÑADIR SUS VARIABLES ESTÁN TODAS COMO VARCHAR EN LA BASE DE DATOS CREADA.
Y EL "ERROR ES EL QUE SIGUE"
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in C:\wamp\www\formclie.php on line 8
ESPERO SU AYUDA Y DESDE YA MIL GRACIAS
Última edición por feuerwehr189; 28/10/2012 a las 23:49
Razón: ME FALTO ALGO
|