Problema al crear tablas MySQL con PHP
Publicado por Diego (4 intervenciones) el 13/02/2014 20:12:52
Hola. Tengo un problema al intentar crear tablas en Mysql con PHP. No me da ningún tipo de fallo pero simplemente la tabla no se me crea. A ver si me podeis ayudar :)
Este es el formulario con el que envío los datos a MySQL.
Y este el PHP que realizo para que la tabla se me cree:
A ver si hay suerte :)
Este es el formulario con el que envío los datos a MySQL.
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
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>alta</title>
</head>
<body>
<div style="text-align: center;">
<h1><span
style="font-weight: bold; color: rgb(204, 0, 0); font-family: Times New Roman,Times,serif;">Ha
seleccionado dar de alta un alumno.</span></h1>
<br>
<br>
<br>
<div style="text-align: left;">INTRODUZCA:<br>
<br>
<form action="alta.php" method="post">
<ul>
<li>NUMERO DE MATRICULA <input name="matricula"><br>
</li>
<li>NOMBRE <input name="nombre"><br>
</li>
<li>NOTA MEDIA <input name="nota"></li>
</ul>
<div style="text-align: center;"><a href="alta.php"><button
name="Enviar">Enviar</button></a><br>
</div>
</form>
</div>
</div>
</body>
</html>
Y este el PHP que realizo para que la tabla se me cree:
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
<?php
$matricula=$_POST ['matricula'];
$nombre=$_POST ['nombre'];
$nota=$_POST ['nota'];
$conexion=mysql_connect("localhost","root","") or die ("Imposible conectar");
mysql_query("create database if not exists clase",$conexion);
$conexion=mysql_connect("localhost","root","") or die ("Imposible conectar");
mysql_select_db("clase",$conexion);
$crear="create table ";
$crear.="alta ";
$crear.="(";
$crear.="$matricula INT PRIMARY KEY, ";
$crear.="$nombre VARCHAR(20), ";
$crear.="$nota INT";
$crear.=")";
mysql_query($crear, $conexion);
if(mysql_close($conexion)){
echo "<h3>Conexion cerrada con exito</h3>";}
else{
echo "no";}
?>
A ver si hay suerte :)
Valora esta pregunta


0