![sin imagen de perfil sin imagen de perfil](/img/anonymouse.png)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
Publicado por Martin (4 intervenciones) el 12/01/2018 04:13:46
Hola que tal soy nuevo en php quiero hacer un simple alta de nuevo registros en una BD de mysql pero me sale un erro e intentado todo pero estoy desesperado y no se que hacer, solo quiero dar de alta 2 simples registros de texto a una tabla de myql pero me da un error
se envio el formulario
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''', '')' at line 1
Este es mi codigo:
Este es el index
ya verifique y si se contecta a una BD y todo esta bien, pero no puedeo dar de alta un simple registro...
Anexo el archivo index y el archivo alta ojala me puedan ayudar...
Muchas gracias Dios les bendiga.
se envio el formulario
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''', '')' at line 1
Este es mi codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!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>Practica PHP</title>
</head>
<body>
<?php
include("conexion.php");
if(isset($_POST['registrar']))
{
echo 'se envio el formulario';
echo "<br>";
$usuario = $_POST['user'];
$pass = $_POST['pass'];
$q = "INSERT INTO simple(Nombre, Contrasena) VALUES '$usuario', '$pass')";
//Run Query
$result = mysql_query($q) or die(mysql_error());
}
mysql_close();
?>
<form name="formulario" method="post" action="">
<input type="text" name="user" maxlength="30" size="40">
<input type="password" name="pass" maxlength="30" size="40">
<input type="submit" value="Registrar" name="registrar">
</form>
<br />
<a href="index.php">Regresar</a>
</body>
</html>
<--Este es mo archivo de conexion.-->
<?php
// datos para la coneccion a mysql
$hostdb= "localhost";
$userdb= "root";
$passdb= "undertaker";
$db= "general2018";
//Realizamos la conexion
$conexion = mysql_connect($hostdb,$userdb,$passdb);
//Estructura de control por si falla
if(!$conexion)
{
die("No he podido conectar porque: ".mysql_error());
}
else {
//echo "si se conecto a bd";
}
//Seleccion la base de datos
mysql_select_db($db,$conexion);
?>
Este es el index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!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>Practica PHP</title>
</head>
<body>
<a href="Practica.php">Insertar nuevo usuario</a>
<br />
<a href="consultar.php">Consultar usuarios</a>
<br />
<a href="modificar.php">Modificar usuario</a>
<br />
<a href="eliminar.php">Eliminar usuario</a>
<br />
</body>
</html>
ya verifique y si se contecta a una BD y todo esta bien, pero no puedeo dar de alta un simple registro...
Anexo el archivo index y el archivo alta ojala me puedan ayudar...
Muchas gracias Dios les bendiga.
Valora esta pregunta
![Me gusta: Está pregunta es útil y esta clara Me gusta: Está pregunta es útil y esta clara](/img/img.png?11.51)
![NO me gusta: Está pregunta no esta clara o no es útil No me gusta: Está pregunta no esta clara o no es útil](/img/img.png?11.51)
0